@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enums/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './orderByDirection';"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directions for ordering
|
|
3
|
+
*/
|
|
4
|
+
export var OrderByDirection;
|
|
5
|
+
(function (OrderByDirection) {
|
|
6
|
+
/**
|
|
7
|
+
* Items are ordered ascending
|
|
8
|
+
*/
|
|
9
|
+
OrderByDirection[OrderByDirection["Ascending"] = 0] = "Ascending";
|
|
10
|
+
/**
|
|
11
|
+
* Items are ordered descending
|
|
12
|
+
*/
|
|
13
|
+
OrderByDirection[OrderByDirection["Descending"] = 1] = "Descending";
|
|
14
|
+
})(OrderByDirection || (OrderByDirection = {}));
|
|
15
|
+
//# sourceMappingURL=orderByDirection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderByDirection.js","sourceRoot":"","sources":["../../../src/enums/orderByDirection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,gBAWX;AAXD,WAAY,gBAAgB;IAExB;;OAEG;IACH,iEAAS,CAAA;IAET;;OAEG;IACH,mEAAU,CAAA;AACd,CAAC,EAXW,gBAAgB,KAAhB,gBAAgB,QAW3B","sourcesContent":["/**\r\n * Directions for ordering\r\n */\r\nexport enum OrderByDirection\r\n{\r\n /**\r\n * Items are ordered ascending\r\n */\r\n Ascending,\r\n \r\n /**\r\n * Items are ordered descending\r\n */\r\n Descending\r\n}"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './initJsDevMode';
|
|
2
|
+
export * from './jsDevMode';
|
|
3
|
+
export * from './encoder/encoder';
|
|
4
|
+
export * from './paginator/paginator';
|
|
5
|
+
export * from './normalizer';
|
|
6
|
+
export * from './enums';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export * from './utils';
|
|
9
|
+
export * from './decorators';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAEzB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC","sourcesContent":["import './initJsDevMode';\r\n\r\nexport * from './jsDevMode';\r\nexport * from './encoder/encoder';\r\nexport * from './paginator/paginator';\r\nexport * from './normalizer';\r\nexport * from './enums';\r\nexport * from './types';\r\nexport * from './utils';\r\nexport * from './decorators';\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexNode.js","sourceRoot":"","sources":["../../src/indexNode.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC","sourcesContent":["export * from './index';"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initJsDevMode.js","sourceRoot":"","sources":["../../src/initJsDevMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhC,YAAY,CAAC,MAAM,CAAC,EAAE;IAElB,IAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAC/B;QACI,MAAM,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;KAC/B;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {globalDefine} from './jsDevMode';\nimport {isBlank} from './utils';\n\nglobalDefine(global =>\n{\n if(isBlank(global['jsDevMode']))\n {\n global['jsDevMode'] = false;\n }\n});\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines global variable
|
|
3
|
+
* @param globalDefineFunc - Global variable definition callback
|
|
4
|
+
*/
|
|
5
|
+
export function globalDefine(globalDefineFunc) {
|
|
6
|
+
globalDefineFunc(typeof window != 'undefined' && window || typeof self != 'undefined' && self || typeof global != 'undefined' && global);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=jsDevMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsDevMode.js","sourceRoot":"","sources":["../../src/jsDevMode.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,gBAAuC;IAEhE,gBAAgB,CAAC,OAAO,MAAM,IAAI,WAAW,IAAI,MAAM,IAAI,OAAO,IAAI,IAAI,WAAW,IAAI,IAAI,IAAI,OAAO,MAAM,IAAI,WAAW,IAAI,MAAM,CAAC,CAAC;AAC7I,CAAC","sourcesContent":["declare global\r\n{\r\n const jsDevMode: boolean;\r\n}\r\n\r\n/**\r\n * Defines global variable\r\n * @param globalDefineFunc - Global variable definition callback\r\n */\r\nexport function globalDefine(globalDefineFunc: (global: any) => void): void\r\n{\r\n globalDefineFunc(typeof window != 'undefined' && window || typeof self != 'undefined' && self || typeof global != 'undefined' && global);\r\n}"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Char map for slovak language
|
|
3
|
+
*/
|
|
4
|
+
export const SlovakCharmap = {
|
|
5
|
+
'áä': 'a',
|
|
6
|
+
'éě': 'e',
|
|
7
|
+
'í': 'i',
|
|
8
|
+
'óô': 'o',
|
|
9
|
+
'úů': 'u',
|
|
10
|
+
'ý': 'y',
|
|
11
|
+
'č': 'c',
|
|
12
|
+
'ď': 'd',
|
|
13
|
+
'ľĺ': 'l',
|
|
14
|
+
'ň': 'n',
|
|
15
|
+
'řŕ': 'r',
|
|
16
|
+
'š': 's',
|
|
17
|
+
'ť': 't',
|
|
18
|
+
'ž': 'z',
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=charMaps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charMaps.js","sourceRoot":"","sources":["../../../src/normalizer/charMaps.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAC1B;IACI,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,GAAG;IACT,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;CACX,CAAC","sourcesContent":["import {StringDictionary} from '../types';\r\n\r\n/**\r\n * Char map for slovak language\r\n */\r\nexport const SlovakCharmap: StringDictionary = \r\n{\r\n 'áä': 'a',\r\n 'éě': 'e',\r\n 'í': 'i',\r\n 'óô': 'o',\r\n 'úů': 'u',\r\n 'ý': 'y',\r\n 'č': 'c',\r\n 'ď': 'd',\r\n 'ľĺ': 'l',\r\n 'ň': 'n',\r\n 'řŕ': 'r',\r\n 'š': 's',\r\n 'ť': 't',\r\n 'ž': 'z',\r\n};"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/normalizer/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC","sourcesContent":["export * from './charMaps';\r\nexport * from './normalizer';"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize strings, removes accent
|
|
3
|
+
* @param str - String to be normalized
|
|
4
|
+
* @param charMap - CharMap used for normalization
|
|
5
|
+
*/
|
|
6
|
+
export function normalize(str, charMap) {
|
|
7
|
+
Object.keys(charMap).forEach(chars => {
|
|
8
|
+
const normalized = charMap[chars];
|
|
9
|
+
const regex = new RegExp('[' + chars + ']', 'gi');
|
|
10
|
+
str = str.replace(regex, normalized);
|
|
11
|
+
});
|
|
12
|
+
return str;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=normalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizer.js","sourceRoot":"","sources":["../../../src/normalizer/normalizer.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,OAAyB;IAE5D,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAEjC,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,KAAK,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC;QAElD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import {StringDictionary} from '../types';\r\n\r\n/**\r\n * Normalize strings, removes accent\r\n * @param str - String to be normalized\r\n * @param charMap - CharMap used for normalization\r\n */\r\nexport function normalize(str: string, charMap: StringDictionary): string\r\n{\r\n Object.keys(charMap).forEach(chars =>\r\n {\r\n const normalized = charMap[chars];\r\n const regex = new RegExp('[' + chars + ']', 'gi');\r\n\r\n str = str.replace(regex, normalized);\r\n });\r\n\r\n return str;\r\n}"]}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class for paging evaluation
|
|
3
|
+
*/
|
|
4
|
+
export class Paginator {
|
|
5
|
+
constructor() {
|
|
6
|
+
//######################### private fields #########################
|
|
7
|
+
/**
|
|
8
|
+
* First page set to paginator
|
|
9
|
+
*/
|
|
10
|
+
this._base = 1;
|
|
11
|
+
/**
|
|
12
|
+
* Number of items per page
|
|
13
|
+
*/
|
|
14
|
+
this._itemsPerPage = 10;
|
|
15
|
+
/**
|
|
16
|
+
* Index of current page
|
|
17
|
+
*/
|
|
18
|
+
this._page = 1;
|
|
19
|
+
/**
|
|
20
|
+
* Number of all items to be used for counting paging
|
|
21
|
+
*/
|
|
22
|
+
this._itemCount = 0;
|
|
23
|
+
}
|
|
24
|
+
//######################### public methods #########################
|
|
25
|
+
/**
|
|
26
|
+
* Sets current page number.
|
|
27
|
+
* @param page - Page number
|
|
28
|
+
* @returns Paginator Provides a fluent interface
|
|
29
|
+
*/
|
|
30
|
+
setPage(page) {
|
|
31
|
+
this._page = page;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns current page number.
|
|
36
|
+
* @returns number Current page number
|
|
37
|
+
*/
|
|
38
|
+
getPage() {
|
|
39
|
+
return this._base + this.getPageIndex();
|
|
40
|
+
}
|
|
41
|
+
/// <summary>
|
|
42
|
+
/// Returns first page number.
|
|
43
|
+
/// </summary>
|
|
44
|
+
/// <returns>Number of first page</returns>
|
|
45
|
+
GetFirstPage() {
|
|
46
|
+
return this._base;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns last page number.
|
|
50
|
+
* @returns number Number of last page
|
|
51
|
+
*/
|
|
52
|
+
getLastPage() {
|
|
53
|
+
return this._base + Math.max(0, this.getPageCount() - 1);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sets first page (base) number.
|
|
57
|
+
* @param baseVal - Index of base page
|
|
58
|
+
* @returns Paginator Provides a fluent interface
|
|
59
|
+
*/
|
|
60
|
+
setBase(baseVal) {
|
|
61
|
+
this._base = baseVal;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns first page (base) number.
|
|
66
|
+
* @returns number Index of base page
|
|
67
|
+
*/
|
|
68
|
+
getBase() {
|
|
69
|
+
return this._base;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gets indication whether is the current page the first one?
|
|
73
|
+
* @returns boolean True if current page is first one
|
|
74
|
+
*/
|
|
75
|
+
isFirst() {
|
|
76
|
+
return this.getPageIndex() == 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets indication whether is the current page the last one?
|
|
80
|
+
* @returns boolean True if current page is last one, otherwise false
|
|
81
|
+
*/
|
|
82
|
+
isLast() {
|
|
83
|
+
return this.getPageIndex() == (this.getPageCount() - 1);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns the total number of pages.
|
|
87
|
+
* @returns number Total number of pages
|
|
88
|
+
*/
|
|
89
|
+
getPageCount() {
|
|
90
|
+
return Math.ceil(this._itemCount / this._itemsPerPage);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Sets the number of items to display on a single page.
|
|
94
|
+
* @param itemsPerPage - Number of items per page
|
|
95
|
+
* @returns Paginator Provides a fluent interface
|
|
96
|
+
*/
|
|
97
|
+
setItemsPerPage(itemsPerPage) {
|
|
98
|
+
this._itemsPerPage = Math.max(1, itemsPerPage);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the number of items to display on a single page.
|
|
103
|
+
* @returns number Number of items per one page
|
|
104
|
+
*/
|
|
105
|
+
getItemsPerPage() {
|
|
106
|
+
return this._itemsPerPage;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Sets the total number of items.
|
|
110
|
+
* @param itemCount - Count of items or -1 for infinity
|
|
111
|
+
* @returns Paginator Provides a fluent interface
|
|
112
|
+
*/
|
|
113
|
+
setItemCount(itemCount) {
|
|
114
|
+
this._itemCount = itemCount == -1 ? Number.MAX_VALUE : Math.max(0, itemCount);
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns the total number of items.
|
|
119
|
+
* @returns number Total number of items
|
|
120
|
+
*/
|
|
121
|
+
getItemCount() {
|
|
122
|
+
return this._itemCount;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Returns the absolute index of the first item on current page.
|
|
126
|
+
* @returns number Absolute index of first item
|
|
127
|
+
*/
|
|
128
|
+
getOffset() {
|
|
129
|
+
return this.getPageIndex() * this._itemsPerPage;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns the absolute index of the first item on current page in countdown paging.
|
|
133
|
+
* @returns number Countdown offset of first item
|
|
134
|
+
*/
|
|
135
|
+
getCountdownOffset() {
|
|
136
|
+
return Math.max(0, this._itemCount - (this.getPageIndex() + 1) * this._itemsPerPage);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Returns the number of items on current page.
|
|
140
|
+
* @returns number Number of items on page
|
|
141
|
+
*/
|
|
142
|
+
getLength() {
|
|
143
|
+
return Math.min(this._itemsPerPage, this._itemCount - this.getPageIndex() * this._itemsPerPage);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Gets indexes for items on current page (zero-based indexes)
|
|
147
|
+
* @returns number Array of items indexes
|
|
148
|
+
*/
|
|
149
|
+
getIndexesPerPage() {
|
|
150
|
+
const result = [];
|
|
151
|
+
if (isNaN(this.getOffset())) {
|
|
152
|
+
for (let x = 0; x < this.getItemCount(); x++) {
|
|
153
|
+
result.push(x);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
for (let x = this.getOffset(); x < this.getOffset() + this.getLength(); x++) {
|
|
158
|
+
result.push(x);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Gets list of page numbers with specified dispersion
|
|
165
|
+
* @param dispersion - Number identifying dispersion
|
|
166
|
+
* @returns number Page numbers according specified dispersion
|
|
167
|
+
*/
|
|
168
|
+
getPagesWithDispersion(dispersion) {
|
|
169
|
+
const currentPage = this.getPage();
|
|
170
|
+
const pageCount = this.getPageCount();
|
|
171
|
+
const numberOfPages = Math.min(pageCount, Math.max(0, dispersion) * 2 + 1) - 1;
|
|
172
|
+
let startingPage = Math.max(this._base, currentPage - dispersion);
|
|
173
|
+
if ((currentPage + dispersion) > pageCount) {
|
|
174
|
+
startingPage = pageCount - numberOfPages;
|
|
175
|
+
}
|
|
176
|
+
let x;
|
|
177
|
+
const endingPage = startingPage + numberOfPages;
|
|
178
|
+
const result = [];
|
|
179
|
+
for (x = startingPage; x <= endingPage; x++) {
|
|
180
|
+
result.push(x);
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Gets list of page numbers with specified dispersion, pages are trimmed if current page is near beginning or end
|
|
186
|
+
* @param dispersion - Number identifying dispersion
|
|
187
|
+
* @returns number Page numbers according specified dispersion
|
|
188
|
+
*/
|
|
189
|
+
getPagesWithTrimDispersion(dispersion) {
|
|
190
|
+
const currentPage = this.getPage();
|
|
191
|
+
const lastPage = this.getLastPage();
|
|
192
|
+
const startingPage = Math.max(this._base, currentPage - dispersion);
|
|
193
|
+
let x;
|
|
194
|
+
const endingPage = Math.min(lastPage, currentPage + dispersion);
|
|
195
|
+
const result = [];
|
|
196
|
+
for (x = startingPage; x <= endingPage; x++) {
|
|
197
|
+
result.push(x);
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Gets list of page numbers generated with uniform distribution
|
|
203
|
+
* @param numberOfPages - Number of pages that are going to be uniformly distributed between first and last page (including)
|
|
204
|
+
* @returns number Uniformly distributed page numbers
|
|
205
|
+
*/
|
|
206
|
+
getPagesWithUniformDistribution(numberOfPages) {
|
|
207
|
+
numberOfPages = Math.max(1, numberOfPages - 1);
|
|
208
|
+
const pageCount = this.getPageCount();
|
|
209
|
+
numberOfPages = Math.min(numberOfPages, pageCount - 1);
|
|
210
|
+
const step = pageCount / numberOfPages;
|
|
211
|
+
let page = this.GetFirstPage();
|
|
212
|
+
let x;
|
|
213
|
+
const result = [];
|
|
214
|
+
for (x = 0; x < numberOfPages; x++) {
|
|
215
|
+
result.push(Math.round(page));
|
|
216
|
+
page += step;
|
|
217
|
+
}
|
|
218
|
+
result.push(pageCount);
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
//######################### protected methods #########################
|
|
222
|
+
/**
|
|
223
|
+
* Returns zero-based page number.
|
|
224
|
+
* @returns number Zero-based page number
|
|
225
|
+
*/
|
|
226
|
+
getPageIndex() {
|
|
227
|
+
return Math.min(Math.max(0, this._page - this._base), Math.max(0, this.getPageCount() - 1));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=paginator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginator.js","sourceRoot":"","sources":["../../../src/paginator/paginator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,SAAS;IAAtB;QAEI,qEAAqE;QAErE;;WAEG;QACK,UAAK,GAAW,CAAC,CAAC;QAE1B;;WAEG;QACK,kBAAa,GAAW,EAAE,CAAC;QAEnC;;WAEG;QACK,UAAK,GAAW,CAAC,CAAC;QAE1B;;WAEG;QACK,eAAU,GAAW,CAAC,CAAC;IAqRnC,CAAC;IAnRG,oEAAoE;IAEpE;;;;OAIG;IACI,OAAO,CAAC,IAAY;QAEvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAElB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,OAAO;QAEV,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAC5C,CAAC;IAED,aAAa;IACb,8BAA8B;IAC9B,cAAc;IACd,2CAA2C;IACpC,YAAY;QAEf,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,WAAW;QAEd,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,OAAe;QAE1B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QAErB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,OAAO;QAEV,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,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MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,EAAE,EAClC;YACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAE9B,IAAI,IAAI,IAAI,CAAC;SAChB;QAED,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEvB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,uEAAuE;IAEvE;;;OAGG;IACO,YAAY;QAElB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;CACJ","sourcesContent":["/**\r\n * Class for paging evaluation\r\n */\r\nexport class Paginator\r\n{\r\n //######################### private fields ######################### \r\n\r\n /**\r\n * First page set to paginator\r\n */\r\n private _base: number = 1;\r\n\r\n /**\r\n * Number of items per page\r\n */\r\n private _itemsPerPage: number = 10;\r\n\r\n /**\r\n * Index of current page\r\n */\r\n private _page: number = 1;\r\n\r\n /**\r\n * Number of all items to be used for counting paging\r\n */\r\n private _itemCount: number = 0;\r\n\r\n //######################### public methods #########################\r\n\r\n /**\r\n * Sets current page number.\r\n * @param page - Page number\r\n * @returns Paginator Provides a fluent interface\r\n */\r\n public setPage(page: number): Paginator\r\n {\r\n this._page = page;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns current page number.\r\n * @returns number Current page number\r\n */\r\n public getPage(): number\r\n {\r\n return this._base + this.getPageIndex();\r\n }\r\n\r\n /// <summary>\r\n /// Returns first page number.\r\n /// </summary>\r\n /// <returns>Number of first page</returns>\r\n public GetFirstPage(): number\r\n {\r\n return this._base;\r\n }\r\n\r\n /**\r\n * Returns last page number.\r\n * @returns number Number of last page\r\n */\r\n public getLastPage(): number\r\n {\r\n return this._base + Math.max(0, this.getPageCount() - 1);\r\n }\r\n\r\n /**\r\n * Sets first page (base) number.\r\n * @param baseVal - Index of base page\r\n * @returns Paginator Provides a fluent interface\r\n */\r\n public setBase(baseVal: number): Paginator\r\n {\r\n this._base = baseVal;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns first page (base) number.\r\n * @returns number Index of base page\r\n */\r\n public getBase(): number\r\n {\r\n return this._base;\r\n }\r\n\r\n /**\r\n * Gets indication whether is the current page the first one?\r\n * @returns boolean True if current page is first one\r\n */\r\n public isFirst(): boolean\r\n {\r\n return this.getPageIndex() == 0;\r\n }\r\n\r\n /**\r\n * Gets indication whether is the current page the last one?\r\n * @returns boolean True if current page is last one, otherwise false\r\n */\r\n public isLast(): boolean\r\n {\r\n return this.getPageIndex() == (this.getPageCount() - 1);\r\n }\r\n\r\n /**\r\n * Returns the total number of pages.\r\n * @returns number Total number of pages\r\n */\r\n public getPageCount(): number\r\n {\r\n return Math.ceil(this._itemCount / this._itemsPerPage);\r\n }\r\n\r\n /**\r\n * Sets the number of items to display on a single page.\r\n * @param itemsPerPage - Number of items per page\r\n * @returns Paginator Provides a fluent interface\r\n */\r\n public setItemsPerPage(itemsPerPage: number): Paginator\r\n {\r\n this._itemsPerPage = Math.max(1, itemsPerPage);\r\n \r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the number of items to display on a single page.\r\n * @returns number Number of items per one page\r\n */\r\n public getItemsPerPage(): number\r\n {\r\n return this._itemsPerPage;\r\n }\r\n\r\n /**\r\n * Sets the total number of items.\r\n * @param itemCount - Count of items or -1 for infinity\r\n * @returns Paginator Provides a fluent interface\r\n */\r\n public setItemCount(itemCount: number): Paginator\r\n {\r\n this._itemCount = itemCount == -1 ? Number.MAX_VALUE : Math.max(0, itemCount);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total number of items.\r\n * @returns number Total number of items\r\n */\r\n public getItemCount(): number\r\n {\r\n return this._itemCount;\r\n }\r\n\r\n /**\r\n * Returns the absolute index of the first item on current page.\r\n * @returns number Absolute index of first item\r\n */\r\n public getOffset(): number\r\n {\r\n return this.getPageIndex() * this._itemsPerPage;\r\n }\r\n\r\n /**\r\n * Returns the absolute index of the first item on current page in countdown paging.\r\n * @returns number Countdown offset of first item\r\n */\r\n public getCountdownOffset(): number\r\n {\r\n return Math.max(0, this._itemCount - (this.getPageIndex() + 1) * this._itemsPerPage);\r\n }\r\n\r\n /**\r\n * Returns the number of items on current page.\r\n * @returns number Number of items on page\r\n */\r\n public getLength(): number\r\n {\r\n return Math.min(this._itemsPerPage, this._itemCount - this.getPageIndex() * this._itemsPerPage);\r\n }\r\n\r\n /**\r\n * Gets indexes for items on current page (zero-based indexes)\r\n * @returns number Array of items indexes\r\n */\r\n public getIndexesPerPage(): number[]\r\n {\r\n const result: number[] = [];\r\n\r\n if(isNaN(this.getOffset()))\r\n {\r\n for(let x = 0; x < this.getItemCount(); x++)\r\n {\r\n result.push(x);\r\n }\r\n }\r\n else\r\n {\r\n for(let x = this.getOffset(); x < this.getOffset() + this.getLength(); x++)\r\n {\r\n result.push(x);\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Gets list of page numbers with specified dispersion\r\n * @param dispersion - Number identifying dispersion\r\n * @returns number Page numbers according specified dispersion\r\n */\r\n public getPagesWithDispersion(dispersion: number): number[]\r\n {\r\n const currentPage = this.getPage();\r\n const pageCount = this.getPageCount();\r\n const numberOfPages = Math.min(pageCount, Math.max(0, dispersion) * 2 + 1) - 1;\r\n let startingPage = Math.max(this._base, currentPage - dispersion);\r\n\r\n if ((currentPage + dispersion) > pageCount)\r\n {\r\n startingPage = pageCount - numberOfPages;\r\n }\r\n\r\n let x: number;\r\n const endingPage = startingPage + numberOfPages;\r\n\r\n const result: number[] = [];\r\n\r\n for (x = startingPage; x <= endingPage; x++)\r\n {\r\n result.push(x);\r\n }\r\n \r\n return result;\r\n }\r\n\r\n /**\r\n * Gets list of page numbers with specified dispersion, pages are trimmed if current page is near beginning or end\r\n * @param dispersion - Number identifying dispersion\r\n * @returns number Page numbers according specified dispersion\r\n */\r\n public getPagesWithTrimDispersion(dispersion: number): number[]\r\n {\r\n const currentPage = this.getPage();\r\n const lastPage = this.getLastPage();\r\n const startingPage = Math.max(this._base, currentPage - dispersion);\r\n let x: number;\r\n const endingPage = Math.min(lastPage, currentPage + dispersion);\r\n\r\n const result: number[] = [];\r\n \r\n for (x = startingPage; x <= endingPage; x++)\r\n {\r\n result.push(x);\r\n }\r\n \r\n return result;\r\n }\r\n\r\n /**\r\n * Gets list of page numbers generated with uniform distribution\r\n * @param numberOfPages - Number of pages that are going to be uniformly distributed between first and last page (including)\r\n * @returns number Uniformly distributed page numbers\r\n */\r\n public getPagesWithUniformDistribution(numberOfPages: number): number[]\r\n {\r\n numberOfPages = Math.max(1, numberOfPages - 1);\r\n const pageCount = this.getPageCount();\r\n numberOfPages = Math.min(numberOfPages, pageCount - 1);\r\n const step = pageCount / numberOfPages;\r\n let page = this.GetFirstPage();\r\n let x;\r\n\r\n const result: number[] = [];\r\n\r\n for (x = 0; x < numberOfPages; x++)\r\n {\r\n result.push(Math.round(page));\r\n\r\n page += step;\r\n }\r\n\r\n result.push(pageCount);\r\n \r\n return result;\r\n }\r\n\r\n //######################### protected methods #########################\r\n\r\n /**\r\n * Returns zero-based page number.\r\n * @returns number Zero-based page number\r\n */\r\n protected getPageIndex(): number\r\n {\r\n return Math.min(Math.max(0, this._page - this._base), Math.max(0, this.getPageCount() - 1));\r\n }\r\n}"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionaries.js","sourceRoot":"","sources":["../../../src/types/dictionaries.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * Represents type that extracts class as type Record with property keys as index and unknown property values\r\n */\r\nexport type AsDictionary<TType extends Object> = TType extends {[P in keyof TType]: unknown} ? Record<keyof TType, unknown> : unknown;\r\n\r\n/**\r\n * Represents Record type where, key is string and value is defined by typeparam\r\n * @typeparam TData - Type of property value\r\n */\r\nexport type Dictionary<TData = unknown> = Record<string, TData>;\r\n\r\n/**\r\n * Represents Record type where, key is string and value is string\r\n */\r\nexport type StringDictionary = Record<string, string>;"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/types/enums.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Type that represents enum type\n */\nexport type Enum<E = unknown> = Record<keyof E, number | string> & {[k: number]: string};"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/types/functions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Function definition with no variables and no return type\n */\nexport type NoopAction = () => void;\n\n/**\n * Function definition with variable arguments and no return type\n */\nexport type Action = (...args: unknown[]) => void;\n\n/**\n * Function definition with variable arguments and return type\n * @typeParam TResult - Return type of function\n */\nexport type Func<TResult = unknown> = (...args: unknown[]) => TResult;"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './dictionaries';\r\nexport * from './enums';\r\nexport * from './functions';\r\nexport * from './valueNamePair';"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueNamePair.js","sourceRoot":"","sources":["../../../src/types/valueNamePair.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * Value name pair data \r\n */\r\nexport interface ValueNamePair\r\n{\r\n /**\r\n * Value of the pair\r\n */\r\n value: string;\r\n \r\n /**\r\n * Name of the pair\r\n */\r\n name: string;\r\n}"]}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import extendLib from 'extend';
|
|
2
|
+
import { isPresent } from './lang';
|
|
3
|
+
import { normalize } from '../normalizer';
|
|
4
|
+
/**
|
|
5
|
+
* Reverse current string and returns new reverse string
|
|
6
|
+
* @param str - String to be reversed
|
|
7
|
+
* @returns string Reverse string
|
|
8
|
+
*/
|
|
9
|
+
export function reverseString(str) {
|
|
10
|
+
return str.split('').reverse().join('');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Extends one object with additional properties from other objects, supports deep extend
|
|
14
|
+
* @param deepOrObject - Object to be extended or indication that deep copy should be performed
|
|
15
|
+
* @param objectN - Objects that will be used for extending, if deep is used first here is target object
|
|
16
|
+
* @returns Object Extended object with properties from other objects
|
|
17
|
+
*/
|
|
18
|
+
export function extend(deepOrObject, ...objectN) {
|
|
19
|
+
return extendLib.apply(null, [deepOrObject, ...objectN]);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generates random string consisting from lowercase letters
|
|
23
|
+
* @param length - Length of generated string
|
|
24
|
+
* @returns number Generated string
|
|
25
|
+
*/
|
|
26
|
+
export function generateId(length) {
|
|
27
|
+
let result = '';
|
|
28
|
+
for (let x = 0; x < length; x++) {
|
|
29
|
+
result += String.fromCharCode(Math.round(Math.random() * 25 + 97));
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Generates random string of specified length from possible characters
|
|
35
|
+
* @param length - Length of generated string
|
|
36
|
+
* @param possible - Possible characters used for generation of string
|
|
37
|
+
*/
|
|
38
|
+
export function generateRandomString(length, possible = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') {
|
|
39
|
+
let text = '';
|
|
40
|
+
for (let i = 0; i < length; i++) {
|
|
41
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
42
|
+
}
|
|
43
|
+
return text;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Converts string in that way that first letter will be lowerCase
|
|
47
|
+
* @param text - Text to be converted
|
|
48
|
+
*/
|
|
49
|
+
export function firstToLowerCase(text) {
|
|
50
|
+
return text.charAt(0).toLowerCase() + text.substr(1);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets indication whether is child descendand of parent
|
|
54
|
+
* @param parent - Parent to be tested
|
|
55
|
+
* @param child - Child to be looked for
|
|
56
|
+
*/
|
|
57
|
+
export function isDescendant(parent, child) {
|
|
58
|
+
let node = child.parentNode;
|
|
59
|
+
while (node != null) {
|
|
60
|
+
if (node == parent) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
node = node.parentNode;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Computes offset of element against document
|
|
69
|
+
* @param element - Html element which offset is counted
|
|
70
|
+
* @param doc - Html document to be used for extracting scroll offset
|
|
71
|
+
*/
|
|
72
|
+
export function offset(element, doc) {
|
|
73
|
+
doc = doc || document;
|
|
74
|
+
const rect = element.getBoundingClientRect(), scrollLeft = window.pageXOffset || doc.documentElement.scrollLeft, scrollTop = window.pageYOffset || doc.documentElement.scrollTop;
|
|
75
|
+
return {
|
|
76
|
+
top: rect.top + scrollTop,
|
|
77
|
+
left: rect.left + scrollLeft,
|
|
78
|
+
bottom: rect.top + scrollTop + rect.height,
|
|
79
|
+
right: rect.left + scrollLeft + rect.width
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Converts html string into html DOM
|
|
84
|
+
* @param html - Html string to be converted to DOM
|
|
85
|
+
* @param doc - Optional html document to be used
|
|
86
|
+
*/
|
|
87
|
+
export function htmlToElement(html, doc) {
|
|
88
|
+
let htmlDocument = document;
|
|
89
|
+
if (isPresent(doc)) {
|
|
90
|
+
htmlDocument = doc;
|
|
91
|
+
}
|
|
92
|
+
const template = htmlDocument.createElement('template');
|
|
93
|
+
html = html.trim();
|
|
94
|
+
template.innerHTML = html;
|
|
95
|
+
return template.content.firstChild;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Extract values from enum type
|
|
99
|
+
* @param enumType - Enum type that will have extracted values
|
|
100
|
+
*/
|
|
101
|
+
export function getEnumValues(enumType) {
|
|
102
|
+
const result = [];
|
|
103
|
+
Object.keys(enumType).forEach(key => {
|
|
104
|
+
if (isNaN(+key)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
result.push({
|
|
108
|
+
value: key,
|
|
109
|
+
name: enumType[+key]
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
export function getValue(object, expression) {
|
|
115
|
+
return expression.split('.').reduce((o, i) => {
|
|
116
|
+
if (o) {
|
|
117
|
+
return o[i];
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}, object);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sets value to objects property using string expression
|
|
124
|
+
* @param object - Object which property value will be set
|
|
125
|
+
* @param value - Value that will be set
|
|
126
|
+
* @param expression - Expression for setting value
|
|
127
|
+
*/
|
|
128
|
+
export function setValue(object, value, expression) {
|
|
129
|
+
const parts = expression.split('.');
|
|
130
|
+
parts.forEach((part, index) => {
|
|
131
|
+
//last item value is assigned
|
|
132
|
+
if (index == parts.length - 1) {
|
|
133
|
+
if (isPresent(value)) {
|
|
134
|
+
object[part] = value;
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
object = object[part] = object[part] ?? {};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Formats string using '%s', to print '%s' you have to use '%%s'
|
|
143
|
+
* @param str - String containing substitution constants
|
|
144
|
+
* @param args - Arguments that are used for replacement
|
|
145
|
+
*/
|
|
146
|
+
export function format(str, ...args) {
|
|
147
|
+
let i = 0;
|
|
148
|
+
return str.replace(/((?!%).)%s/g, (_sub, substArgs) => `${substArgs[0]}${args[i++]}`).replace(/%%s/g, '%s');
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Performs flatMap over provided array
|
|
152
|
+
* @param array - Array to be reduced using flatMap
|
|
153
|
+
*/
|
|
154
|
+
export function flatMapArray(array) {
|
|
155
|
+
return array.reduce((acc, x) => acc.concat(x), []);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Serialize object to string that is usable as url query parameter
|
|
159
|
+
* @param obj - Object to be serialized
|
|
160
|
+
* @param replacer - Function that can be used for replacing provided values
|
|
161
|
+
*/
|
|
162
|
+
export function serializeToUrlQuery(obj, replacer) {
|
|
163
|
+
return btoa(encodeURIComponent(JSON.stringify(obj, replacer)));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Deserialize value from url query string into object
|
|
167
|
+
* @param queryParamValue - Query param string value
|
|
168
|
+
* @param reviver - Function that can be used for correctly deserializing value
|
|
169
|
+
*/
|
|
170
|
+
export function deserializeFromUrlQuery(queryParamValue, reviver) {
|
|
171
|
+
return JSON.parse(decodeURIComponent(atob(queryParamValue)), reviver);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Converts id to valid html id
|
|
175
|
+
* @param id - Id that is going to be converted to valid html id
|
|
176
|
+
* @param charMap - Character map used during normalization
|
|
177
|
+
*/
|
|
178
|
+
export function validHtmlId(id, charMap = {}) {
|
|
179
|
+
id = id.toLowerCase()
|
|
180
|
+
.replace(/[\s]+/g, '-')
|
|
181
|
+
.replace(/\./g, '')
|
|
182
|
+
.replace(/^(\d)/g, 'x$1');
|
|
183
|
+
id = normalize(id, charMap);
|
|
184
|
+
return id;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Checks whether is element overflown either horizontal, or vertical
|
|
188
|
+
* @param element - Element to be tested for overflow
|
|
189
|
+
*/
|
|
190
|
+
export function isOverflown(element) {
|
|
191
|
+
return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Normalizes string, removing accent
|
|
195
|
+
* @param value - String to be normalized
|
|
196
|
+
*/
|
|
197
|
+
export function normalizeAccent(value) {
|
|
198
|
+
return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Converts instance of Class to equivalent Record type
|
|
202
|
+
* @param instance - Instance which type to be converted
|
|
203
|
+
* @typeparam TType - Type of instance
|
|
204
|
+
*/
|
|
205
|
+
export function asDictionary(instance) {
|
|
206
|
+
return instance;
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=common.js.map
|