@jscrpt/common 1.2.0 → 2.0.0-beta.20211108120022
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/changelog.md +24 -0
- package/dist/es2015/decorators/bindThis.decorator.js +24 -24
- package/dist/es2015/decorators/bindThis.decorator.js.map +1 -0
- package/dist/es2015/decorators/callOnce.decorator.js +29 -28
- package/dist/es2015/decorators/callOnce.decorator.js.map +1 -0
- package/dist/es2015/decorators/debounceCall.decorator.js +25 -26
- package/dist/es2015/decorators/debounceCall.decorator.js.map +1 -0
- package/dist/es2015/decorators/index.js +4 -4
- package/dist/es2015/decorators/index.js.map +1 -0
- package/dist/es2015/encoder/encoder.js +220 -231
- package/dist/es2015/encoder/encoder.js.map +1 -0
- package/dist/es2015/enums/index.js +2 -2
- package/dist/es2015/enums/index.js.map +1 -0
- package/dist/es2015/enums/orderByDirection.js +15 -15
- package/dist/es2015/enums/orderByDirection.js.map +1 -0
- package/dist/es2015/index.js +10 -24
- package/dist/es2015/index.js.map +1 -0
- package/dist/es2015/indexNode.js +2 -2
- package/dist/es2015/indexNode.js.map +1 -0
- package/dist/es2015/initJsDevMode.js +8 -0
- package/dist/es2015/initJsDevMode.js.map +1 -0
- package/dist/es2015/jsDevMode.js +8 -8
- package/dist/es2015/jsDevMode.js.map +1 -0
- package/dist/es2015/normalizer/charMaps.js +20 -27
- package/dist/es2015/normalizer/charMaps.js.map +1 -0
- package/dist/es2015/normalizer/index.js +3 -3
- package/dist/es2015/normalizer/index.js.map +1 -0
- package/dist/es2015/normalizer/normalizer.js +14 -14
- package/dist/es2015/normalizer/normalizer.js.map +1 -0
- package/dist/es2015/paginator/paginator.js +230 -224
- package/dist/es2015/paginator/paginator.js.map +1 -0
- package/dist/es2015/types/dictionaries.js +2 -1
- package/dist/es2015/types/dictionaries.js.map +1 -0
- package/dist/es2015/types/enums.js +2 -0
- package/dist/es2015/types/enums.js.map +1 -0
- package/dist/es2015/types/functions.js +2 -0
- package/dist/es2015/types/functions.js.map +1 -0
- package/dist/es2015/types/index.js +5 -3
- package/dist/es2015/types/index.js.map +1 -0
- package/dist/es2015/types/valueNamePair.js +2 -1
- package/dist/es2015/types/valueNamePair.js.map +1 -0
- package/dist/es2015/utils/common.js +209 -215
- package/dist/es2015/utils/common.js.map +1 -0
- package/dist/es2015/utils/index.js +4 -4
- package/dist/es2015/utils/index.js.map +1 -0
- package/dist/es2015/utils/lang.js +79 -79
- package/dist/es2015/utils/lang.js.map +1 -0
- package/dist/es2015/utils/nameof.js +6 -6
- package/dist/es2015/utils/nameof.js.map +1 -0
- package/dist/es2020/decorators/bindThis.decorator.js +23 -0
- package/dist/es2020/decorators/bindThis.decorator.js.map +1 -0
- package/dist/es2020/decorators/callOnce.decorator.js +28 -0
- package/dist/es2020/decorators/callOnce.decorator.js.map +1 -0
- package/dist/es2020/decorators/debounceCall.decorator.js +24 -0
- package/dist/es2020/decorators/debounceCall.decorator.js.map +1 -0
- package/dist/es2020/decorators/index.js +4 -0
- package/dist/es2020/decorators/index.js.map +1 -0
- package/dist/es2020/encoder/encoder.js +220 -0
- package/dist/es2020/encoder/encoder.js.map +1 -0
- package/dist/es2020/enums/index.js +2 -0
- package/dist/es2020/enums/index.js.map +1 -0
- package/dist/es2020/enums/orderByDirection.js +15 -0
- package/dist/es2020/enums/orderByDirection.js.map +1 -0
- package/dist/es2020/index.js +10 -0
- package/dist/es2020/index.js.map +1 -0
- package/dist/es2020/indexNode.js +2 -0
- package/dist/es2020/indexNode.js.map +1 -0
- package/dist/es2020/initJsDevMode.js +8 -0
- package/dist/es2020/initJsDevMode.js.map +1 -0
- package/dist/es2020/jsDevMode.js +8 -0
- package/dist/es2020/jsDevMode.js.map +1 -0
- package/dist/es2020/normalizer/charMaps.js +20 -0
- package/dist/es2020/normalizer/charMaps.js.map +1 -0
- package/dist/es2020/normalizer/index.js +3 -0
- package/dist/es2020/normalizer/index.js.map +1 -0
- package/dist/es2020/normalizer/normalizer.js +14 -0
- package/dist/es2020/normalizer/normalizer.js.map +1 -0
- package/dist/es2020/paginator/paginator.js +230 -0
- package/dist/es2020/paginator/paginator.js.map +1 -0
- package/dist/es2020/types/dictionaries.js +2 -0
- package/dist/es2020/types/dictionaries.js.map +1 -0
- package/dist/es2020/types/enums.js +2 -0
- package/dist/es2020/types/enums.js.map +1 -0
- package/dist/es2020/types/functions.js +2 -0
- package/dist/es2020/types/functions.js.map +1 -0
- package/dist/es2020/types/index.js +5 -0
- package/dist/es2020/types/index.js.map +1 -0
- package/dist/es2020/types/valueNamePair.js +2 -0
- package/dist/es2020/types/valueNamePair.js.map +1 -0
- package/dist/es2020/utils/common.js +208 -0
- package/dist/es2020/utils/common.js.map +1 -0
- package/dist/es2020/utils/index.js +4 -0
- package/dist/es2020/utils/index.js.map +1 -0
- package/dist/es2020/utils/lang.js +79 -0
- package/dist/es2020/utils/lang.js.map +1 -0
- package/dist/es2020/utils/nameof.js +6 -0
- package/dist/es2020/utils/nameof.js.map +1 -0
- package/dist/es5/decorators/bindThis.decorator.js +24 -24
- package/dist/es5/decorators/bindThis.decorator.js.map +1 -0
- package/dist/es5/decorators/callOnce.decorator.js +33 -28
- package/dist/es5/decorators/callOnce.decorator.js.map +1 -0
- package/dist/es5/decorators/debounceCall.decorator.js +30 -27
- package/dist/es5/decorators/debounceCall.decorator.js.map +1 -0
- package/dist/es5/decorators/index.js +4 -4
- package/dist/es5/decorators/index.js.map +1 -0
- package/dist/es5/encoder/encoder.js +222 -233
- package/dist/es5/encoder/encoder.js.map +1 -0
- package/dist/es5/enums/index.js +2 -2
- package/dist/es5/enums/index.js.map +1 -0
- package/dist/es5/enums/orderByDirection.js +15 -15
- package/dist/es5/enums/orderByDirection.js.map +1 -0
- package/dist/es5/index.js +10 -24
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/indexNode.js +2 -2
- package/dist/es5/indexNode.js.map +1 -0
- package/dist/es5/initJsDevMode.js +8 -0
- package/dist/es5/initJsDevMode.js.map +1 -0
- package/dist/es5/jsDevMode.js +8 -8
- package/dist/es5/jsDevMode.js.map +1 -0
- package/dist/es5/normalizer/charMaps.js +20 -35
- package/dist/es5/normalizer/charMaps.js.map +1 -0
- package/dist/es5/normalizer/index.js +3 -3
- package/dist/es5/normalizer/index.js.map +1 -0
- package/dist/es5/normalizer/normalizer.js +14 -14
- package/dist/es5/normalizer/normalizer.js.map +1 -0
- package/dist/es5/paginator/paginator.js +232 -226
- package/dist/es5/paginator/paginator.js.map +1 -0
- package/dist/es5/types/dictionaries.js +2 -1
- package/dist/es5/types/dictionaries.js.map +1 -0
- package/dist/es5/types/enums.js +2 -0
- package/dist/es5/types/enums.js.map +1 -0
- package/dist/es5/types/functions.js +2 -0
- package/dist/es5/types/functions.js.map +1 -0
- package/dist/es5/types/index.js +5 -3
- package/dist/es5/types/index.js.map +1 -0
- package/dist/es5/types/valueNamePair.js +2 -1
- package/dist/es5/types/valueNamePair.js.map +1 -0
- package/dist/es5/utils/common.js +220 -232
- package/dist/es5/utils/common.js.map +1 -0
- package/dist/es5/utils/index.js +4 -4
- package/dist/es5/utils/index.js.map +1 -0
- package/dist/es5/utils/lang.js +79 -79
- package/dist/es5/utils/lang.js.map +1 -0
- package/dist/es5/utils/nameof.js +6 -6
- package/dist/es5/utils/nameof.js.map +1 -0
- package/dist/module/decorators/bindThis.decorator.js +28 -28
- package/dist/module/decorators/bindThis.decorator.js.map +1 -0
- package/dist/module/decorators/callOnce.decorator.js +33 -32
- package/dist/module/decorators/callOnce.decorator.js.map +1 -0
- package/dist/module/decorators/debounceCall.decorator.js +29 -30
- package/dist/module/decorators/debounceCall.decorator.js.map +1 -0
- package/dist/module/decorators/index.js +7 -16
- package/dist/module/decorators/index.js.map +1 -0
- package/dist/module/encoder/encoder.js +224 -235
- package/dist/module/encoder/encoder.js.map +1 -0
- package/dist/module/enums/index.js +5 -14
- package/dist/module/enums/index.js.map +1 -0
- package/dist/module/enums/orderByDirection.js +18 -18
- package/dist/module/enums/orderByDirection.js.map +1 -0
- package/dist/module/index.js +13 -37
- package/dist/module/index.js.map +1 -0
- package/dist/module/indexNode.js +5 -14
- package/dist/module/indexNode.js.map +1 -0
- package/dist/module/initJsDevMode.js +10 -0
- package/dist/module/initJsDevMode.js.map +1 -0
- package/dist/module/jsDevMode.js +12 -12
- package/dist/module/jsDevMode.js.map +1 -0
- package/dist/module/normalizer/charMaps.js +23 -31
- package/dist/module/normalizer/charMaps.js.map +1 -0
- package/dist/module/normalizer/index.js +6 -15
- package/dist/module/normalizer/index.js.map +1 -0
- package/dist/module/normalizer/normalizer.js +18 -18
- package/dist/module/normalizer/normalizer.js.map +1 -0
- package/dist/module/paginator/paginator.js +234 -228
- package/dist/module/paginator/paginator.js.map +1 -0
- package/dist/module/types/dictionaries.js +3 -3
- package/dist/module/types/dictionaries.js.map +1 -0
- package/dist/module/types/enums.js +3 -0
- package/dist/module/types/enums.js.map +1 -0
- package/dist/module/types/functions.js +3 -0
- package/dist/module/types/functions.js.map +1 -0
- package/dist/module/types/index.js +8 -15
- package/dist/module/types/index.js.map +1 -0
- package/dist/module/types/valueNamePair.js +3 -3
- package/dist/module/types/valueNamePair.js.map +1 -0
- package/dist/module/utils/common.js +232 -240
- package/dist/module/utils/common.js.map +1 -0
- package/dist/module/utils/index.js +7 -16
- package/dist/module/utils/index.js.map +1 -0
- package/dist/module/utils/lang.js +99 -99
- package/dist/module/utils/lang.js.map +1 -0
- package/dist/module/utils/nameof.js +10 -9
- package/dist/module/utils/nameof.js.map +1 -0
- package/package.json +45 -16
- package/src/decorators/bindThis.decorator.d.ts +5 -7
- package/src/decorators/bindThis.decorator.d.ts.map +1 -1
- package/src/decorators/callOnce.decorator.d.ts +5 -5
- package/src/decorators/callOnce.decorator.d.ts.map +1 -1
- package/src/decorators/debounceCall.decorator.d.ts +5 -5
- package/src/decorators/debounceCall.decorator.d.ts.map +1 -1
- package/src/decorators/index.d.ts +3 -3
- package/src/encoder/encoder.d.ts +45 -45
- package/src/encoder/encoder.d.ts.map +1 -1
- package/src/enums/index.d.ts +1 -1
- package/src/enums/orderByDirection.d.ts +13 -13
- package/src/index.d.ts +9 -17
- package/src/index.d.ts.map +1 -1
- package/src/indexNode.d.ts +1 -1
- package/src/initJsDevMode.d.ts +2 -0
- package/src/initJsDevMode.d.ts.map +1 -0
- package/src/jsDevMode.d.ts +8 -8
- package/src/jsDevMode.d.ts.map +1 -1
- package/src/normalizer/charMaps.d.ts +5 -9
- package/src/normalizer/charMaps.d.ts.map +1 -1
- package/src/normalizer/index.d.ts +2 -2
- package/src/normalizer/normalizer.d.ts +7 -6
- package/src/normalizer/normalizer.d.ts.map +1 -1
- package/src/paginator/paginator.d.ts +129 -129
- package/src/paginator/paginator.d.ts.map +1 -1
- package/src/types/dictionaries.d.ts +15 -6
- package/src/types/dictionaries.d.ts.map +1 -1
- package/src/types/enums.d.ts +7 -0
- package/src/types/enums.d.ts.map +1 -0
- package/src/types/functions.d.ts +14 -0
- package/src/types/functions.d.ts.map +1 -0
- package/src/types/index.d.ts +4 -2
- package/src/types/index.d.ts.map +1 -1
- package/src/types/valueNamePair.d.ts +13 -13
- package/src/utils/common.d.ts +181 -122
- package/src/utils/common.d.ts.map +1 -1
- package/src/utils/index.d.ts +3 -3
- package/src/utils/lang.d.ts +41 -41
- package/src/utils/lang.d.ts.map +1 -1
- package/src/utils/nameof.d.ts +5 -5
- package/src/utils/nameof.d.ts.map +1 -1
- package/version.bak +1 -1
- package/.jsbeautifyrc +0 -7
- package/appveyor.yml +0 -67
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests whether is object not `null` and not `undefined` at the same time
|
|
3
|
-
* @param obj - Object to be tested
|
|
4
|
-
*/
|
|
5
|
-
export function isPresent(obj) {
|
|
6
|
-
return obj !== undefined && obj !== null;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Tests whether is object `null` or `undefined`
|
|
10
|
-
* @param obj - Object to be tested
|
|
11
|
-
*/
|
|
12
|
-
export function isBlank(obj) {
|
|
13
|
-
return obj === undefined || obj === null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Tests whether is object instance of `boolean`
|
|
17
|
-
* @param obj - Object to be tested
|
|
18
|
-
*/
|
|
19
|
-
export function isBoolean(obj) {
|
|
20
|
-
return typeof obj === 'boolean';
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Tests whether is object instance of number
|
|
24
|
-
* @param obj - Object to be tested
|
|
25
|
-
*/
|
|
26
|
-
export function isNumber(obj) {
|
|
27
|
-
return typeof obj === 'number';
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Tests whether is object instance of string
|
|
31
|
-
* @param obj - Object to be tested
|
|
32
|
-
*/
|
|
33
|
-
export function isString(obj) {
|
|
34
|
-
return typeof obj === 'string';
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Tests whether is object instance of function
|
|
38
|
-
* @param obj - Object to be tested
|
|
39
|
-
*/
|
|
40
|
-
export function isFunction(obj) {
|
|
41
|
-
return typeof obj === 'function';
|
|
42
|
-
}
|
|
43
|
-
export function isType(obj) {
|
|
44
|
-
return isFunction(obj);
|
|
45
|
-
}
|
|
46
|
-
export function isStringMap(obj) {
|
|
47
|
-
return typeof obj === 'object' && obj !== null;
|
|
48
|
-
}
|
|
49
|
-
const STRING_MAP_PROTO = Object.getPrototypeOf({});
|
|
50
|
-
export function isStrictStringMap(obj) {
|
|
51
|
-
return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
|
|
52
|
-
}
|
|
53
|
-
export function isArray(obj) {
|
|
54
|
-
return Array.isArray(obj);
|
|
55
|
-
}
|
|
56
|
-
export function isDate(obj) {
|
|
57
|
-
return obj instanceof Date && !isNaN(obj.valueOf());
|
|
58
|
-
}
|
|
59
|
-
export function noop() {
|
|
60
|
-
}
|
|
61
|
-
export function normalizeBlank(obj) {
|
|
62
|
-
return isBlank(obj) ? null : obj;
|
|
63
|
-
}
|
|
64
|
-
export function isJsObject(o) {
|
|
65
|
-
return o !== null && (typeof o === 'function' || typeof o === 'object');
|
|
66
|
-
}
|
|
67
|
-
export function isPrimitive(obj) {
|
|
68
|
-
return !isJsObject(obj);
|
|
69
|
-
}
|
|
70
|
-
export function hasConstructor(value, type) {
|
|
71
|
-
return value.constructor === type;
|
|
72
|
-
}
|
|
73
|
-
export function isEmptyObject(obj) {
|
|
74
|
-
for (
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=
|
|
1
|
+
/**
|
|
2
|
+
* Tests whether is object not `null` and not `undefined` at the same time
|
|
3
|
+
* @param obj - Object to be tested
|
|
4
|
+
*/
|
|
5
|
+
export function isPresent(obj) {
|
|
6
|
+
return obj !== undefined && obj !== null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Tests whether is object `null` or `undefined`
|
|
10
|
+
* @param obj - Object to be tested
|
|
11
|
+
*/
|
|
12
|
+
export function isBlank(obj) {
|
|
13
|
+
return obj === undefined || obj === null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Tests whether is object instance of `boolean`
|
|
17
|
+
* @param obj - Object to be tested
|
|
18
|
+
*/
|
|
19
|
+
export function isBoolean(obj) {
|
|
20
|
+
return typeof obj === 'boolean';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Tests whether is object instance of number
|
|
24
|
+
* @param obj - Object to be tested
|
|
25
|
+
*/
|
|
26
|
+
export function isNumber(obj) {
|
|
27
|
+
return typeof obj === 'number';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tests whether is object instance of string
|
|
31
|
+
* @param obj - Object to be tested
|
|
32
|
+
*/
|
|
33
|
+
export function isString(obj) {
|
|
34
|
+
return typeof obj === 'string';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Tests whether is object instance of function
|
|
38
|
+
* @param obj - Object to be tested
|
|
39
|
+
*/
|
|
40
|
+
export function isFunction(obj) {
|
|
41
|
+
return typeof obj === 'function';
|
|
42
|
+
}
|
|
43
|
+
export function isType(obj) {
|
|
44
|
+
return isFunction(obj);
|
|
45
|
+
}
|
|
46
|
+
export function isStringMap(obj) {
|
|
47
|
+
return typeof obj === 'object' && obj !== null;
|
|
48
|
+
}
|
|
49
|
+
const STRING_MAP_PROTO = Object.getPrototypeOf({});
|
|
50
|
+
export function isStrictStringMap(obj) {
|
|
51
|
+
return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
|
|
52
|
+
}
|
|
53
|
+
export function isArray(obj) {
|
|
54
|
+
return Array.isArray(obj);
|
|
55
|
+
}
|
|
56
|
+
export function isDate(obj) {
|
|
57
|
+
return obj instanceof Date && !isNaN(obj.valueOf());
|
|
58
|
+
}
|
|
59
|
+
export function noop() {
|
|
60
|
+
}
|
|
61
|
+
export function normalizeBlank(obj) {
|
|
62
|
+
return isBlank(obj) ? null : obj;
|
|
63
|
+
}
|
|
64
|
+
export function isJsObject(o) {
|
|
65
|
+
return o !== null && (typeof o === 'function' || typeof o === 'object');
|
|
66
|
+
}
|
|
67
|
+
export function isPrimitive(obj) {
|
|
68
|
+
return !isJsObject(obj);
|
|
69
|
+
}
|
|
70
|
+
export function hasConstructor(value, type) {
|
|
71
|
+
return value.constructor === type;
|
|
72
|
+
}
|
|
73
|
+
export function isEmptyObject(obj) {
|
|
74
|
+
for (const _name in obj) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/utils/lang.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAO,GAAS;IAErC,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,CAAC;AAC7C,CAAC;AAED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AU,IAAI;AAGpB,CAAC;AAED,MAAM,UAAU,cAAc,CAAsB,GAAwB;IAExE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAM;IAE7B,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,UAAU,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAQ;IAEhC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,IAAS;IAEnD,OAAO,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAQ;IAElC,KAAK,MAAM,KAAK,IAAI,GAAG,EACvB;QACI,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/**\r\n * Tests whether is object not `null` and not `undefined` at the same time\r\n * @param obj - Object to be tested\r\n */\r\nexport function isPresent<TObj>(obj: TObj): obj is NonNullable<TObj>\r\n{\r\n return obj !== undefined && obj !== null;\r\n}\r\n\r\n/**\r\n * Tests whether is object `null` or `undefined`\r\n * @param obj - Object to be tested\r\n */\r\nexport function isBlank(obj: any): obj is null|undefined\r\n{\r\n return obj === undefined || obj === null;\r\n}\r\n\r\n/**\r\n * Tests whether is object instance of `boolean`\r\n * @param obj - Object to be tested\r\n */\r\nexport function isBoolean(obj: any): obj is boolean\r\n{\r\n return typeof obj === 'boolean';\r\n}\r\n\r\n/**\r\n * Tests whether is object instance of number\r\n * @param obj - Object to be tested\r\n */\r\nexport function isNumber(obj: any): obj is number\r\n{\r\n return typeof obj === 'number';\r\n}\r\n\r\n/**\r\n * Tests whether is object instance of string\r\n * @param obj - Object to be tested\r\n */\r\nexport function isString(obj: any): obj is string\r\n{\r\n return typeof obj === 'string';\r\n}\r\n\r\n/**\r\n * Tests whether is object instance of function\r\n * @param obj - Object to be tested\r\n */\r\nexport function isFunction(obj: any): obj is Function\r\n{\r\n return typeof obj === 'function';\r\n}\r\n\r\nexport function isType(obj: any): obj is Function\r\n{\r\n return isFunction(obj);\r\n}\r\n\r\nexport function isStringMap(obj: any): obj is Object\r\n{\r\n return typeof obj === 'object' && obj !== null;\r\n}\r\n\r\nconst STRING_MAP_PROTO = Object.getPrototypeOf({});\r\n\r\nexport function isStrictStringMap(obj: any): boolean\r\n{\r\n return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;\r\n}\r\n\r\nexport function isArray(obj: any): obj is Array<any>\r\n{\r\n return Array.isArray(obj);\r\n}\r\n\r\nexport function isDate(obj: any): obj is Date\r\n{\r\n return obj instanceof Date && !isNaN(obj.valueOf());\r\n}\r\n\r\nexport function noop(): void\r\n// eslint-disable-next-line @typescript-eslint/no-empty-function\r\n{\r\n}\r\n\r\nexport function normalizeBlank<TObj extends Object>(obj: TObj|undefined|null): TObj|null\r\n{\r\n return isBlank(obj) ? null : obj;\r\n}\r\n\r\nexport function isJsObject(o: any): o is Function|Object\r\n{\r\n return o !== null && (typeof o === 'function' || typeof o === 'object');\r\n}\r\n\r\nexport function isPrimitive(obj: any): boolean\r\n{\r\n return !isJsObject(obj);\r\n}\r\n\r\nexport function hasConstructor(value: Object, type: any): boolean\r\n{\r\n return value.constructor === type;\r\n}\r\n\r\nexport function isEmptyObject(obj: any): boolean\r\n{\r\n for (const _name in obj)\r\n {\r\n return false;\r\n }\r\n\r\n return true;\r\n}"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns name of property, checked by typescript
|
|
3
|
-
* @param name - Name of property that should be returned
|
|
4
|
-
*/
|
|
5
|
-
export const nameof = (name) => name;
|
|
6
|
-
//# sourceMappingURL=
|
|
1
|
+
/**
|
|
2
|
+
* Returns name of property, checked by typescript
|
|
3
|
+
* @param name - Name of property that should be returned
|
|
4
|
+
*/
|
|
5
|
+
export const nameof = (name) => name;
|
|
6
|
+
//# sourceMappingURL=nameof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nameof.js","sourceRoot":"","sources":["../../../src/utils/nameof.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAI,IAA8B,EAAU,EAAE,CAAC,IAAI,CAAC","sourcesContent":["/**\r\n * Returns name of property, checked by typescript\r\n * @param name - Name of property that should be returned\r\n */\r\nexport const nameof = <T>(name: Extract<keyof T, string>): string => name;"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isFunction } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Binds function to this, object instance where is defined, it is importat to place it in correct order with other decorators, usually should be first
|
|
4
|
+
*/
|
|
5
|
+
export function BindThis(_target, propertyKey, descriptor) {
|
|
6
|
+
const originalValue = descriptor.value ?? descriptor.get?.();
|
|
7
|
+
if (!isFunction(originalValue)) {
|
|
8
|
+
throw new Error(`Unable to apply @BindThis decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
configurable: true,
|
|
12
|
+
get() {
|
|
13
|
+
const bound = originalValue.bind(this);
|
|
14
|
+
Object.defineProperty(this, propertyKey, {
|
|
15
|
+
value: bound,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true
|
|
18
|
+
});
|
|
19
|
+
return bound;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=bindThis.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindThis.decorator.js","sourceRoot":"","sources":["../../../src/decorators/bindThis.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,WAA0B,EAAE,UAA8B;IAEhG,MAAM,aAAa,GAAS,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;IAEnE,IAAG,CAAC,UAAU,CAAC,aAAa,CAAC,EAC7B;QACI,MAAM,IAAI,KAAK,CAAC,2CAA2C,WAAW,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;KAC9G;IAED,OAAO;QACH,YAAY,EAAE,IAAI;QAClB,GAAG;YAEC,MAAM,KAAK,GAAS,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE7C,MAAM,CAAC,cAAc,CAAC,IAAI,EACJ,WAAW,EACX;gBACI,KAAK,EAAE,KAAK;gBACZ,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACjB,CAAC,CAAC;YAEzB,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;AACN,CAAC","sourcesContent":["import {Func} from '../types';\r\nimport {isFunction} from '../utils';\r\n\r\n/**\r\n * Binds function to this, object instance where is defined, it is importat to place it in correct order with other decorators, usually should be first\r\n */\r\nexport function BindThis(_target: Object, propertyKey: string|symbol, descriptor: PropertyDescriptor): TypedPropertyDescriptor<Func>\r\n{\r\n const originalValue: Func = descriptor.value ?? descriptor.get?.();\r\n\r\n if(!isFunction(originalValue))\r\n {\r\n throw new Error(`Unable to apply @BindThis decorator to '${propertyKey.toString()}', it is not a method.`);\r\n }\r\n\r\n return {\r\n configurable: true,\r\n get(this: unknown): Func\r\n {\r\n const bound: Func = originalValue.bind(this);\r\n\r\n Object.defineProperty(this,\r\n propertyKey,\r\n {\r\n value: bound,\r\n configurable: true,\r\n writable: true\r\n });\r\n\r\n return bound;\r\n }\r\n };\r\n}"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isFunction, isPresent } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Method is called only once for specified time, other calls during this time are blocked and it does nothing and returns null
|
|
4
|
+
* @param time - Number of miliseconds which specifies period while are calls to this method blocked after first call
|
|
5
|
+
*/
|
|
6
|
+
export function CallOnce(time) {
|
|
7
|
+
return function (_target, propertyKey, descriptor) {
|
|
8
|
+
let timeout;
|
|
9
|
+
const originalValue = descriptor.value ?? descriptor.get?.();
|
|
10
|
+
if (!isFunction(originalValue)) {
|
|
11
|
+
throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
12
|
+
}
|
|
13
|
+
descriptor.value = function (...args) {
|
|
14
|
+
if (isPresent(timeout)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
originalValue.apply(this, args);
|
|
18
|
+
timeout = setTimeout(() => {
|
|
19
|
+
if (isPresent(timeout)) {
|
|
20
|
+
clearTimeout(timeout);
|
|
21
|
+
}
|
|
22
|
+
timeout = null;
|
|
23
|
+
}, time);
|
|
24
|
+
};
|
|
25
|
+
return descriptor;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=callOnce.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callOnce.decorator.js","sourceRoot":"","sources":["../../../src/decorators/callOnce.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IAEjC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;QAEvF,IAAI,OAAoB,CAAC;QACzB,MAAM,aAAa,GAAS,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;QAEnE,IAAG,CAAC,UAAU,CAAC,aAAa,CAAC,EAC7B;YACI,MAAM,IAAI,KAAK,CAAC,6CAA6C,WAAW,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;SAChH;QAED,UAAU,CAAC,KAAK,GAAG,UAAS,GAAG,IAAe;YAE1C,IAAG,SAAS,CAAC,OAAO,CAAC,EACrB;gBACI,OAAO;aACV;YAED,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEhC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBAEtB,IAAG,SAAS,CAAC,OAAO,CAAC,EACrB;oBACI,YAAY,CAAC,OAAO,CAAC,CAAC;iBACzB;gBAED,OAAO,GAAG,IAAI,CAAC;YACnB,CAAC,EAAE,IAAI,CAAQ,CAAC;QACpB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {Func} from '../types';\r\nimport {isFunction, isPresent} from '../utils';\r\n\r\n/**\r\n * Method is called only once for specified time, other calls during this time are blocked and it does nothing and returns null\r\n * @param time - Number of miliseconds which specifies period while are calls to this method blocked after first call\r\n */\r\nexport function CallOnce(time: number): MethodDecorator\r\n{\r\n return function(_target: Object, propertyKey: string|symbol, descriptor: PropertyDescriptor)\r\n {\r\n let timeout: number|null;\r\n const originalValue: Func = descriptor.value ?? descriptor.get?.();\r\n\r\n if(!isFunction(originalValue))\r\n {\r\n throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey.toString()}', it is not a method.`);\r\n }\r\n\r\n descriptor.value = function(...args: unknown[]): void\r\n {\r\n if(isPresent(timeout))\r\n {\r\n return;\r\n }\r\n\r\n originalValue.apply(this, args);\r\n\r\n timeout = setTimeout(() =>\r\n {\r\n if(isPresent(timeout))\r\n {\r\n clearTimeout(timeout);\r\n }\r\n \r\n timeout = null;\r\n }, time) as any;\r\n };\r\n\r\n return descriptor;\r\n };\r\n}"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isFunction, isPresent } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Adds special functionality to method call, that debounce method call for specified time
|
|
4
|
+
* @param delay - Number of miliseconds that delays function call
|
|
5
|
+
*/
|
|
6
|
+
export function DebounceCall(delay) {
|
|
7
|
+
return function (_target, propertyKey, descriptor) {
|
|
8
|
+
let timeout;
|
|
9
|
+
const originalValue = descriptor.value ?? descriptor.get?.();
|
|
10
|
+
if (!isFunction(originalValue)) {
|
|
11
|
+
throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
12
|
+
}
|
|
13
|
+
descriptor.value = function (...args) {
|
|
14
|
+
if (isPresent(timeout)) {
|
|
15
|
+
clearTimeout(timeout);
|
|
16
|
+
}
|
|
17
|
+
timeout = setTimeout(() => {
|
|
18
|
+
originalValue.apply(this, args);
|
|
19
|
+
}, delay);
|
|
20
|
+
};
|
|
21
|
+
return descriptor;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=debounceCall.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounceCall.decorator.js","sourceRoot":"","sources":["../../../src/decorators/debounceCall.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IAEtC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;QAEvF,IAAI,OAAe,CAAC;QACpB,MAAM,aAAa,GAAS,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;QAEnE,IAAG,CAAC,UAAU,CAAC,aAAa,CAAC,EAC7B;YACI,MAAM,IAAI,KAAK,CAAC,iDAAiD,WAAW,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;SACpH;QAED,UAAU,CAAC,KAAK,GAAG,UAAS,GAAG,IAAe;YAE1C,IAAG,SAAS,CAAC,OAAO,CAAC,EACrB;gBACI,YAAY,CAAC,OAAO,CAAC,CAAC;aACzB;YAED,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBAEtB,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACpC,CAAC,EAAE,KAAK,CAAQ,CAAC;QACrB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {Func} from '../types';\r\nimport {isFunction, isPresent} from '../utils';\r\n\r\n/**\r\n * Adds special functionality to method call, that debounce method call for specified time\r\n * @param delay - Number of miliseconds that delays function call\r\n */\r\nexport function DebounceCall(delay: number): MethodDecorator\r\n{\r\n return function(_target: Object, propertyKey: string|symbol, descriptor: PropertyDescriptor)\r\n {\r\n let timeout: number;\r\n const originalValue: Func = descriptor.value ?? descriptor.get?.();\r\n\r\n if(!isFunction(originalValue))\r\n {\r\n throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey.toString()}', it is not a method.`);\r\n }\r\n\r\n descriptor.value = function(...args: unknown[]): void\r\n {\r\n if(isPresent(timeout))\r\n {\r\n clearTimeout(timeout);\r\n }\r\n\r\n timeout = setTimeout(() =>\r\n {\r\n originalValue.apply(this, args);\r\n }, delay) as any;\r\n };\r\n\r\n return descriptor;\r\n };\r\n}"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './bindThis.decorator';\r\nexport * from './callOnce.decorator';\r\nexport * from './debounceCall.decorator';"]}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Javascript object to encode and/or decode html characters using HTML or Numeric entities that handles double or partial encoding
|
|
3
|
+
* Author: R Reid
|
|
4
|
+
* source: http://www.strictly-software.com/htmlencode
|
|
5
|
+
* Licences: GPL, The MIT License (MIT)
|
|
6
|
+
* Copyright: (c) 2011 Robert Reid - Strictly-Software.com
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
11
|
+
*
|
|
12
|
+
* Revision:
|
|
13
|
+
* 2011-07-14, Jacques-Yves Bleau:
|
|
14
|
+
* - fixed conversion error with capitalized accentuated characters
|
|
15
|
+
* + converted arr1 and arr2 to object property to remove redundancy
|
|
16
|
+
*
|
|
17
|
+
* Revision:
|
|
18
|
+
* 2011-11-10, Ce-Yi Hio:
|
|
19
|
+
* - fixed conversion error with a number of capitalized entity characters
|
|
20
|
+
*
|
|
21
|
+
* Revision:
|
|
22
|
+
* 2011-11-10, Rob Reid:
|
|
23
|
+
* - changed array format
|
|
24
|
+
*
|
|
25
|
+
* Revision:
|
|
26
|
+
* 2012-09-23, Alex Oss:
|
|
27
|
+
* - replaced string concatonation in numEncode with string builder, push and join for peformance with ammendments by Rob Reid
|
|
28
|
+
*/
|
|
29
|
+
export class Encoder {
|
|
30
|
+
constructor() {
|
|
31
|
+
// When encoding do we convert characters into html or numerical entities
|
|
32
|
+
this.EncodeType = 'entity'; // entity OR numerical
|
|
33
|
+
// arrays for conversion from HTML Entities to Numerical values
|
|
34
|
+
this.arr1 = [' ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', '"', '&', '<', '>', 'Œ', 'œ', 'Š', 'š', 'Ÿ', 'ˆ', '˜', ' ', ' ', ' ', '‌', '‍', '‎', '‏', '–', '—', '‘', '’', '‚', '“', '”', '„', '†', '‡', '‰', '‹', '›', '€', 'ƒ', 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'ς', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', 'ϑ', 'ϒ', 'ϖ', '•', '…', '′', '″', '‾', '⁄', '℘', 'ℑ', 'ℜ', '™', 'ℵ', '←', '↑', '→', '↓', '↔', '↵', '⇐', '⇑', '⇒', '⇓', '⇔', '∀', '∂', '∃', '∅', '∇', '∈', '∉', '∋', '∏', '∑', '−', '∗', '√', '∝', '∞', '∠', '∧', '∨', '∩', '∪', '∫', '∴', '∼', '≅', '≈', '≠', '≡', '≤', '≥', '⊂', '⊃', '⊄', '⊆', '⊇', '⊕', '⊗', '⊥', '⋅', '⌈', '⌉', '⌊', '⌋', '⟨', '⟩', '◊', '♠', '♣', '♥', '♦'];
|
|
35
|
+
this.arr2 = [' ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', '"', '&', '<', '>', 'Œ', 'œ', 'Š', 'š', 'Ÿ', 'ˆ', '˜', ' ', ' ', ' ', '‌', '‍', '‎', '‏', '–', '—', '‘', '’', '‚', '“', '”', '„', '†', '‡', '‰', '‹', '›', '€', 'ƒ', 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'ς', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', 'ϑ', 'ϒ', 'ϖ', '•', '…', '′', '″', '‾', '⁄', '℘', 'ℑ', 'ℜ', '™', 'ℵ', '←', '↑', '→', '↓', '↔', '↵', '⇐', '⇑', '⇒', '⇓', '⇔', '∀', '∂', '∃', '∅', '∇', '∈', '∉', '∋', '∏', '∑', '−', '∗', '√', '∝', '∞', '∠', '∧', '∨', '∩', '∪', '∫', '∴', '∼', '≅', '≈', '≠', '≡', '≤', '≥', '⊂', '⊃', '⊄', '⊆', '⊇', '⊕', '⊗', '⊥', '⋅', '⌈', '⌉', '⌊', '⌋', '〈', '〉', '◊', '♠', '♣', '♥', '♦'];
|
|
36
|
+
}
|
|
37
|
+
isEmpty(val) {
|
|
38
|
+
if (val) {
|
|
39
|
+
return ((val === null) || val.length == 0 || /^\s+$/.test(val));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Convert HTML entities into numerical entities
|
|
46
|
+
HTML2Numerical(s) {
|
|
47
|
+
return this.swapArrayVals(s, this.arr1, this.arr2);
|
|
48
|
+
}
|
|
49
|
+
// Convert Numerical entities into HTML entities
|
|
50
|
+
NumericalToHTML(s) {
|
|
51
|
+
return this.swapArrayVals(s, this.arr2, this.arr1);
|
|
52
|
+
}
|
|
53
|
+
// Numerically encodes all unicode characters
|
|
54
|
+
numEncode(s) {
|
|
55
|
+
if (this.isEmpty(s)) {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
const a = [], l = s.length;
|
|
59
|
+
for (let i = 0; i < l; i++) {
|
|
60
|
+
const c = s.charAt(i);
|
|
61
|
+
if (c < ' ' || c > '~') {
|
|
62
|
+
a.push('&#');
|
|
63
|
+
a.push(c.charCodeAt()); //numeric value of code point
|
|
64
|
+
a.push(';');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
a.push(c);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return a.join('');
|
|
71
|
+
}
|
|
72
|
+
// HTML Decode numerical and HTML entities back to original values
|
|
73
|
+
htmlDecode(s) {
|
|
74
|
+
let c, m, d = s;
|
|
75
|
+
if (this.isEmpty(d)) {
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
// convert HTML entites back to numerical entites first
|
|
79
|
+
d = this.HTML2Numerical(d);
|
|
80
|
+
// look for numerical entities "
|
|
81
|
+
const arr = d.match(/&#[0-9]{1,5};/g);
|
|
82
|
+
// if no matches found in string then skip
|
|
83
|
+
if (arr != null) {
|
|
84
|
+
for (let x = 0; x < arr.length; x++) {
|
|
85
|
+
m = arr[x];
|
|
86
|
+
c = m.substring(2, m.length - 1); //get numeric part which is refernce to unicode character
|
|
87
|
+
// if its a valid number we can decode
|
|
88
|
+
if (c >= -32768 && c <= 65535) {
|
|
89
|
+
// decode every single match within string
|
|
90
|
+
d = d.replace(m, String.fromCharCode(c));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
d = d.replace(m, ''); //invalid so replace with nada
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return d;
|
|
98
|
+
}
|
|
99
|
+
// encode an input string into either numerical or HTML entities
|
|
100
|
+
htmlEncode(s, dbl) {
|
|
101
|
+
if (this.isEmpty(s)) {
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
104
|
+
// do we allow double encoding? E.g will & be turned into &amp;
|
|
105
|
+
dbl = dbl || false; //default to prevent double encoding
|
|
106
|
+
// if allowing double encoding we do ampersands first
|
|
107
|
+
if (dbl) {
|
|
108
|
+
if (this.EncodeType == 'numerical') {
|
|
109
|
+
s = s.replace(/&/g, '&');
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
s = s.replace(/&/g, '&');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// convert the xss chars to numerical entities ' ' < >
|
|
116
|
+
s = this.XSSEncode(s, false);
|
|
117
|
+
if (this.EncodeType == 'numerical' || !dbl) {
|
|
118
|
+
// Now call function that will convert any HTML entities to numerical codes
|
|
119
|
+
s = this.HTML2Numerical(s);
|
|
120
|
+
}
|
|
121
|
+
// Now encode all chars above 127 e.g unicode
|
|
122
|
+
s = this.numEncode(s);
|
|
123
|
+
// now we know anything that needs to be encoded has been converted to numerical entities we
|
|
124
|
+
// can encode any ampersands & that are not part of encoded entities
|
|
125
|
+
// to handle the fact that I need to do a negative check and handle multiple ampersands &&&
|
|
126
|
+
// I am going to use a placeholder
|
|
127
|
+
// if we don't want double encoded entities we ignore the & in existing entities
|
|
128
|
+
if (!dbl) {
|
|
129
|
+
s = s.replace(/&#/g, '##AMPHASH##');
|
|
130
|
+
if (this.EncodeType == 'numerical') {
|
|
131
|
+
s = s.replace(/&/g, '&');
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
s = s.replace(/&/g, '&');
|
|
135
|
+
}
|
|
136
|
+
s = s.replace(/##AMPHASH##/g, '&#');
|
|
137
|
+
}
|
|
138
|
+
// replace any malformed entities
|
|
139
|
+
s = s.replace(/&#\d*([^\d;]|$)/g, '$1');
|
|
140
|
+
if (!dbl) {
|
|
141
|
+
// safety check to correct any double encoded &
|
|
142
|
+
s = this.correctEncoding(s);
|
|
143
|
+
}
|
|
144
|
+
// now do we need to convert our numerical encoded string into entities
|
|
145
|
+
if (this.EncodeType == 'entity') {
|
|
146
|
+
s = this.NumericalToHTML(s);
|
|
147
|
+
}
|
|
148
|
+
return s;
|
|
149
|
+
}
|
|
150
|
+
// Encodes the basic 4 characters used to malform HTML in XSS hacks
|
|
151
|
+
XSSEncode(s, en) {
|
|
152
|
+
if (!this.isEmpty(s)) {
|
|
153
|
+
en = en || true;
|
|
154
|
+
// do we convert to numerical or html entity?
|
|
155
|
+
if (en) {
|
|
156
|
+
s = s.replace(/'/g, '''); //no HTML equivalent as &apos is not cross browser supported
|
|
157
|
+
s = s.replace(/"/g, '"');
|
|
158
|
+
s = s.replace(/</g, '<');
|
|
159
|
+
s = s.replace(/>/g, '>');
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
s = s.replace(/'/g, '''); //no HTML equivalent as &apos is not cross browser supported
|
|
163
|
+
s = s.replace(/"/g, '"');
|
|
164
|
+
s = s.replace(/</g, '<');
|
|
165
|
+
s = s.replace(/>/g, '>');
|
|
166
|
+
}
|
|
167
|
+
return s;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
return '';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// returns true if a string contains html or numerical encoded entities
|
|
174
|
+
hasEncoded(s) {
|
|
175
|
+
if (/&#[0-9]{1,5};/g.test(s)) {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
else if (/&[A-Z]{2,6};/gi.test(s)) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// will remove any unicode characters
|
|
186
|
+
stripUnicode(s) {
|
|
187
|
+
return s.replace(/[^\x20-\x7E]/g, '');
|
|
188
|
+
}
|
|
189
|
+
// corrects any double encoded & entities e.g &amp;
|
|
190
|
+
correctEncoding(s) {
|
|
191
|
+
return s.replace(/(&)(amp;)+/, '$1');
|
|
192
|
+
}
|
|
193
|
+
// Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals
|
|
194
|
+
swapArrayVals(s, arr1, arr2) {
|
|
195
|
+
if (this.isEmpty(s)) {
|
|
196
|
+
return '';
|
|
197
|
+
}
|
|
198
|
+
let re;
|
|
199
|
+
if (arr1 && arr2) {
|
|
200
|
+
//ShowDebug('in swapArrayVals arr1.length = ' + arr1.length + ' arr2.length = ' + arr2.length)
|
|
201
|
+
// array lengths must match
|
|
202
|
+
if (arr1.length == arr2.length) {
|
|
203
|
+
for (let x = 0, i = arr1.length; x < i; x++) {
|
|
204
|
+
re = new RegExp(arr1[x], 'g');
|
|
205
|
+
s = s.replace(re, arr2[x]); //swap arr1 item with matching item from arr2
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return s;
|
|
210
|
+
}
|
|
211
|
+
inArray(item, arr) {
|
|
212
|
+
for (let i = 0, x = arr.length; i < x; i++) {
|
|
213
|
+
if (arr[i] === item) {
|
|
214
|
+
return i;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return -1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../../src/encoder/encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,OAAO,OAAO;IAApB;QAEI,yEAAyE;QACzE,eAAU,GAAW,QAAQ,CAAC,CAAE,sBAAsB;QActD,+DAA+D;QAC/D,SAAI,GAAa,CAAC,QAAQ,EAAC,SAAS,EAAC,QAAQ,EAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAC,UAAU,EAAC,QAAQ,EAAC,OAAO,EAAC,QAAQ,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAC,OAAO,EAAC,UAAU,EAAC,QAAQ,EAAC,QAAQ,EAAC,SAAS,EAAC,SAAS,EAAC,QAAQ,EAAC,UAAU,EAAC,SAAS,EAAC,QAAQ,EAAC,QAAQ,EAAC,SAAS,EAAC,UAAU,EAAC,UAAU,EAAC,UAAU,EAAC,UAAU,EAAC,UAAU,EAAC,UAAU,EAAC,SAAS,EAAC,UAAU,EAAC,QAAQ,EAAC,SAAS,EAAC,SAAS,EAAC,UAAU,EAAC,UAAU,EAAC,UAAU,EAAC,SAAS,EAAC,QAAQ,EAAC,UAAU,EAAC,UAAU,EAAC,SAAS,EAAC,QAAQ,EAAC,OAAO,EAAC,UAAU,EAAC,UAAU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AAO,CAAC,CAAC,CAAC,EAClB;YACI,OAAO,EAAE,CAAC;SACb;QAED,IAAI,EAAE,CAAC;QAEP,IAAG,IAAI,IAAI,IAAI,EACf;YACI,8FAA8F;YAC9F,2BAA2B;YAC3B,IAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAC7B;gBACI,KAAI,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EACxC;oBACI,EAAE,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;oBAC9B,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,6CAA6C;iBAC3E;aACJ;SACJ;QAED,OAAO,CAAC,CAAC;IACb,CAAC;IAED,OAAO,CAAE,IAAQ,EAAE,GAAO;QAEtB,KAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAC3C;YACI,IAAK,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EACpB;gBACI,OAAO,CAAC,CAAC;aACZ;SACJ;QAED,OAAO,CAAC,CAAC,CAAC;IACd,CAAC;CAEJ","sourcesContent":["/**\r\n * A Javascript object to encode and/or decode html characters using HTML or Numeric entities that handles double or partial encoding\r\n * Author: R Reid\r\n * source: http://www.strictly-software.com/htmlencode\r\n * Licences: GPL, The MIT License (MIT)\r\n * Copyright: (c) 2011 Robert Reid - Strictly-Software.com\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n *\r\n * Revision:\r\n * 2011-07-14, Jacques-Yves Bleau:\r\n * - fixed conversion error with capitalized accentuated characters\r\n * + converted arr1 and arr2 to object property to remove redundancy\r\n *\r\n * Revision:\r\n * 2011-11-10, Ce-Yi Hio:\r\n * - fixed conversion error with a number of capitalized entity characters\r\n *\r\n * Revision:\r\n * 2011-11-10, Rob Reid:\r\n * - changed array format\r\n *\r\n * Revision:\r\n * 2012-09-23, Alex Oss:\r\n * - replaced string concatonation in numEncode with string builder, push and join for peformance with ammendments by Rob Reid\r\n */\r\n\r\nexport class Encoder\r\n{\r\n // When encoding do we convert characters into html or numerical entities\r\n EncodeType: string = 'entity'; // entity OR numerical\r\n\r\n isEmpty(val: any): boolean\r\n {\r\n if(val)\r\n {\r\n return ((val===null) || val.length==0 || /^\\s+$/.test(val));\r\n }\r\n else\r\n {\r\n return true;\r\n }\r\n }\r\n\r\n // arrays for conversion from HTML Entities to Numerical values\r\n arr1: string[] = [' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','Œ','œ','Š','š','Ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','‡','‰','‹','›','€','ƒ','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','″','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','⇐','⇑','⇒','⇓','⇔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','⟨','⟩','◊','♠','♣','♥','♦'];\r\n arr2: string[] = [' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','Œ','œ','Š','š','Ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','‡','‰','‹','›','€','ƒ','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','″','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','⇐','⇑','⇒','⇓','⇔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','〈','〉','◊','♠','♣','♥','♦'];\r\n\r\n // Convert HTML entities into numerical entities\r\n HTML2Numerical(s:any)\r\n {\r\n return this.swapArrayVals(s, this.arr1, this.arr2);\r\n }\r\n\r\n // Convert Numerical entities into HTML entities\r\n NumericalToHTML(s:any)\r\n {\r\n return this.swapArrayVals(s, this.arr2, this.arr1);\r\n }\r\n\r\n\r\n // Numerically encodes all unicode characters\r\n numEncode(s:any)\r\n {\r\n if(this.isEmpty(s))\r\n { \r\n return '';\r\n }\r\n\r\n const a = [],\r\n l = s.length;\r\n\r\n for (let i=0; i < l; i++)\r\n {\r\n const c = s.charAt(i);\r\n \r\n if (c < ' ' || c > '~')\r\n {\r\n a.push('&#');\r\n a.push(c.charCodeAt()); //numeric value of code point\r\n a.push(';');\r\n }\r\n else\r\n {\r\n a.push(c);\r\n }\r\n }\r\n\r\n return a.join('');\r\n }\r\n\r\n // HTML Decode numerical and HTML entities back to original values\r\n htmlDecode(s:any)\r\n {\r\n let c,m,d = s;\r\n\r\n if(this.isEmpty(d)) \r\n {\r\n return '';\r\n }\r\n\r\n // convert HTML entites back to numerical entites first\r\n d = this.HTML2Numerical(d);\r\n\r\n // look for numerical entities "\r\n const arr = d.match(/&#[0-9]{1,5};/g);\r\n\r\n // if no matches found in string then skip\r\n if(arr!=null)\r\n {\r\n for(let x=0; x < arr.length; x++)\r\n {\r\n m = arr[x];\r\n c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character\r\n // if its a valid number we can decode\r\n if(c >= -32768 && c <= 65535)\r\n {\r\n // decode every single match within string\r\n d = d.replace(m, String.fromCharCode(c));\r\n }\r\n else\r\n {\r\n d = d.replace(m, ''); //invalid so replace with nada\r\n }\r\n }\r\n }\r\n\r\n return d;\r\n }\r\n\r\n // encode an input string into either numerical or HTML entities\r\n htmlEncode(s:any, dbl:any)\r\n {\r\n if(this.isEmpty(s))\r\n {\r\n return '';\r\n }\r\n\r\n // do we allow double encoding? E.g will & be turned into &amp;\r\n dbl = dbl || false; //default to prevent double encoding\r\n\r\n // if allowing double encoding we do ampersands first\r\n if(dbl)\r\n {\r\n if(this.EncodeType=='numerical')\r\n {\r\n s = s.replace(/&/g, '&');\r\n }\r\n else\r\n {\r\n s = s.replace(/&/g, '&');\r\n }\r\n }\r\n\r\n // convert the xss chars to numerical entities ' ' < >\r\n s = this.XSSEncode(s,false);\r\n\r\n if(this.EncodeType=='numerical' || !dbl)\r\n {\r\n // Now call function that will convert any HTML entities to numerical codes\r\n s = this.HTML2Numerical(s);\r\n }\r\n\r\n // Now encode all chars above 127 e.g unicode\r\n s = this.numEncode(s);\r\n\r\n // now we know anything that needs to be encoded has been converted to numerical entities we\r\n // can encode any ampersands & that are not part of encoded entities\r\n // to handle the fact that I need to do a negative check and handle multiple ampersands &&&\r\n // I am going to use a placeholder\r\n\r\n // if we don't want double encoded entities we ignore the & in existing entities\r\n if(!dbl)\r\n {\r\n s = s.replace(/&#/g,'##AMPHASH##');\r\n\r\n if(this.EncodeType=='numerical')\r\n {\r\n s = s.replace(/&/g, '&');\r\n }\r\n else\r\n {\r\n s = s.replace(/&/g, '&');\r\n }\r\n\r\n s = s.replace(/##AMPHASH##/g,'&#');\r\n }\r\n\r\n // replace any malformed entities\r\n s = s.replace(/&#\\d*([^\\d;]|$)/g, '$1');\r\n\r\n if(!dbl)\r\n {\r\n // safety check to correct any double encoded &\r\n s = this.correctEncoding(s);\r\n }\r\n\r\n // now do we need to convert our numerical encoded string into entities\r\n if(this.EncodeType=='entity')\r\n {\r\n s = this.NumericalToHTML(s);\r\n }\r\n\r\n return s;\r\n }\r\n\r\n // Encodes the basic 4 characters used to malform HTML in XSS hacks\r\n XSSEncode(s:any,en:any)\r\n {\r\n if(!this.isEmpty(s))\r\n {\r\n en = en || true;\r\n // do we convert to numerical or html entity?\r\n if(en)\r\n {\r\n s = s.replace(/'/g,'''); //no HTML equivalent as &apos is not cross browser supported\r\n s = s.replace(/\"/g,'"');\r\n s = s.replace(/</g,'<');\r\n s = s.replace(/>/g,'>');\r\n }\r\n else\r\n {\r\n s = s.replace(/'/g,'''); //no HTML equivalent as &apos is not cross browser supported\r\n s = s.replace(/\"/g,'"');\r\n s = s.replace(/</g,'<');\r\n s = s.replace(/>/g,'>');\r\n }\r\n \r\n return s;\r\n }\r\n else\r\n {\r\n return '';\r\n }\r\n }\r\n\r\n // returns true if a string contains html or numerical encoded entities\r\n hasEncoded(s:any)\r\n {\r\n if(/&#[0-9]{1,5};/g.test(s))\r\n {\r\n return true;\r\n }\r\n else if(/&[A-Z]{2,6};/gi.test(s))\r\n {\r\n return true;\r\n }\r\n else\r\n {\r\n return false;\r\n }\r\n }\r\n\r\n // will remove any unicode characters\r\n stripUnicode(s:any)\r\n {\r\n return s.replace(/[^\\x20-\\x7E]/g,'');\r\n }\r\n\r\n // corrects any double encoded & entities e.g &amp;\r\n correctEncoding(s:any)\r\n {\r\n return s.replace(/(&)(amp;)+/,'$1');\r\n }\r\n\r\n // Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals\r\n swapArrayVals(s:any,arr1:any,arr2:any)\r\n {\r\n if(this.isEmpty(s))\r\n { \r\n return '';\r\n }\r\n \r\n let re;\r\n \r\n if(arr1 && arr2)\r\n {\r\n //ShowDebug('in swapArrayVals arr1.length = ' + arr1.length + ' arr2.length = ' + arr2.length)\r\n // array lengths must match\r\n if(arr1.length == arr2.length)\r\n {\r\n for(let x=0, i = arr1.length; x < i; x++)\r\n {\r\n re = new RegExp(arr1[x], 'g');\r\n s = s.replace(re,arr2[x]); //swap arr1 item with matching item from arr2\r\n }\r\n }\r\n }\r\n \r\n return s;\r\n }\r\n\r\n inArray( item:any, arr:any ) \r\n {\r\n for ( let i = 0, x = arr.length; i < x; i++ )\r\n {\r\n if ( arr[i] === item )\r\n {\r\n return i;\r\n }\r\n }\r\n \r\n return -1;\r\n }\r\n\r\n}\r\n"]}
|