@jscrpt/common 2.3.0 → 3.0.0-beta.20220907063712

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.
Files changed (114) hide show
  1. package/changelog.md +36 -0
  2. package/es/rxjs/src/utils/async.js.map +1 -1
  3. package/es/rxjs/src/utils/async.mjs +10 -4
  4. package/es/src/decorators/bindThis.decorator.js.map +1 -1
  5. package/es/src/decorators/callOnce.decorator.js.map +1 -1
  6. package/es/src/decorators/callOnce.decorator.mjs +13 -6
  7. package/es/src/decorators/debounceCall.decorator.js.map +1 -1
  8. package/es/src/decorators/debounceCall.decorator.mjs +34 -6
  9. package/es/src/decorators/withSync.decorator.js.map +1 -0
  10. package/es/src/decorators/withSync.decorator.mjs +33 -0
  11. package/es/src/index.js.map +1 -1
  12. package/es/src/index.mjs +2 -1
  13. package/es/src/types/dictionaries.js.map +1 -1
  14. package/es/src/types/functions.js.map +1 -1
  15. package/es/src/types/invalidatable.js.map +1 -0
  16. package/es/src/types/invalidatable.mjs +2 -0
  17. package/es/src/utils/common.js.map +1 -1
  18. package/es2015/rxjs/src/utils/async.js +10 -4
  19. package/es2015/rxjs/src/utils/async.js.map +1 -1
  20. package/es2015/src/decorators/bindThis.decorator.js.map +1 -1
  21. package/es2015/src/decorators/callOnce.decorator.js +13 -6
  22. package/es2015/src/decorators/callOnce.decorator.js.map +1 -1
  23. package/es2015/src/decorators/debounceCall.decorator.js +34 -6
  24. package/es2015/src/decorators/debounceCall.decorator.js.map +1 -1
  25. package/es2015/src/decorators/withSync.decorator.js +33 -0
  26. package/es2015/src/decorators/withSync.decorator.js.map +1 -0
  27. package/es2015/src/index.js +2 -1
  28. package/es2015/src/index.js.map +1 -1
  29. package/es2015/src/types/dictionaries.js.map +1 -1
  30. package/es2015/src/types/functions.js.map +1 -1
  31. package/es2015/src/types/invalidatable.js +2 -0
  32. package/es2015/src/types/invalidatable.js.map +1 -0
  33. package/es2015/src/utils/common.js.map +1 -1
  34. package/es2020/rxjs/src/utils/async.js +10 -4
  35. package/es2020/rxjs/src/utils/async.js.map +1 -1
  36. package/es2020/src/decorators/callOnce.decorator.js +13 -6
  37. package/es2020/src/decorators/callOnce.decorator.js.map +1 -1
  38. package/es2020/src/decorators/debounceCall.decorator.js +32 -5
  39. package/es2020/src/decorators/debounceCall.decorator.js.map +1 -1
  40. package/es2020/src/decorators/withSync.decorator.js +29 -0
  41. package/es2020/src/decorators/withSync.decorator.js.map +1 -0
  42. package/es2020/src/index.js +2 -1
  43. package/es2020/src/index.js.map +1 -1
  44. package/es2020/src/types/dictionaries.js.map +1 -1
  45. package/es2020/src/types/functions.js.map +1 -1
  46. package/es2020/src/types/invalidatable.js +2 -0
  47. package/es2020/src/types/invalidatable.js.map +1 -0
  48. package/es2020/src/utils/common.js.map +1 -1
  49. package/es5/rxjs/src/utils/async.js +10 -4
  50. package/es5/rxjs/src/utils/async.js.map +1 -1
  51. package/es5/src/decorators/bindThis.decorator.js.map +1 -1
  52. package/es5/src/decorators/callOnce.decorator.js +14 -6
  53. package/es5/src/decorators/callOnce.decorator.js.map +1 -1
  54. package/es5/src/decorators/debounceCall.decorator.js +45 -6
  55. package/es5/src/decorators/debounceCall.decorator.js.map +1 -1
  56. package/es5/src/decorators/withSync.decorator.js +47 -0
  57. package/es5/src/decorators/withSync.decorator.js.map +1 -0
  58. package/es5/src/index.js +2 -1
  59. package/es5/src/index.js.map +1 -1
  60. package/es5/src/types/dictionaries.js.map +1 -1
  61. package/es5/src/types/functions.js.map +1 -1
  62. package/es5/src/types/invalidatable.js +2 -0
  63. package/es5/src/types/invalidatable.js.map +1 -0
  64. package/es5/src/utils/common.js.map +1 -1
  65. package/module/rxjs/src/index.cjs +2 -2
  66. package/module/rxjs/src/index.js.map +1 -1
  67. package/module/rxjs/src/utils/async.cjs +9 -3
  68. package/module/rxjs/src/utils/async.js.map +1 -1
  69. package/module/src/decorators/bindThis.decorator.js.map +1 -1
  70. package/module/src/decorators/callOnce.decorator.cjs +13 -6
  71. package/module/src/decorators/callOnce.decorator.js.map +1 -1
  72. package/module/src/decorators/debounceCall.decorator.cjs +34 -6
  73. package/module/src/decorators/debounceCall.decorator.js.map +1 -1
  74. package/module/src/decorators/withSync.decorator.cjs +37 -0
  75. package/module/src/decorators/withSync.decorator.js.map +1 -0
  76. package/module/src/index.cjs +22 -21
  77. package/module/src/index.js.map +1 -1
  78. package/module/src/indexNode.cjs +1 -1
  79. package/module/src/indexNode.js.map +1 -1
  80. package/module/src/types/dictionaries.js.map +1 -1
  81. package/module/src/types/functions.js.map +1 -1
  82. package/module/src/types/invalidatable.cjs +3 -0
  83. package/module/src/types/invalidatable.js.map +1 -0
  84. package/module/src/utils/common.cjs +1 -1
  85. package/module/src/utils/common.js.map +1 -1
  86. package/package.json +8 -8
  87. package/rxjs/src/utils/async.d.ts.map +1 -1
  88. package/src/decorators/callOnce.decorator.d.ts.map +1 -1
  89. package/src/decorators/debounceCall.decorator.d.ts.map +1 -1
  90. package/src/decorators/withSync.decorator.d.ts +5 -0
  91. package/src/decorators/withSync.decorator.d.ts.map +1 -0
  92. package/src/index.d.ts +2 -1
  93. package/src/index.d.ts.map +1 -1
  94. package/src/types/dictionaries.d.ts +2 -2
  95. package/src/types/dictionaries.d.ts.map +1 -1
  96. package/src/types/functions.d.ts +75 -0
  97. package/src/types/functions.d.ts.map +1 -1
  98. package/src/types/invalidatable.d.ts +10 -0
  99. package/src/types/invalidatable.d.ts.map +1 -0
  100. package/src/utils/common.d.ts +1 -1
  101. package/src/utils/common.d.ts.map +1 -1
  102. package/version.bak +1 -1
  103. package/es/src/utils/async.js.map +0 -1
  104. package/es/src/utils/async.mjs +0 -14
  105. package/es2015/src/utils/async.js +0 -14
  106. package/es2015/src/utils/async.js.map +0 -1
  107. package/es2020/src/utils/async.js +0 -11
  108. package/es2020/src/utils/async.js.map +0 -1
  109. package/es5/src/utils/async.js +0 -19
  110. package/es5/src/utils/async.js.map +0 -1
  111. package/module/src/utils/async.cjs +0 -18
  112. package/module/src/utils/async.js.map +0 -1
  113. package/src/utils/async.d.ts +0 -7
  114. package/src/utils/async.d.ts.map +0 -1
package/changelog.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 3.0.0 (2022-09-06)
4
+
5
+ ### Bug Fixes
6
+
7
+ - fixed `CallOnce` decorator
8
+ - now correctly sets timeout to attached method and object
9
+ - fixed `DebounceCall` decorator
10
+ - now correctly sets timeout to attached method and object
11
+
12
+ ### Features
13
+
14
+ - new `Func1` type, that is function definition with one argument and return type
15
+ - new `Func2` type, that is function definition with two arguments and return type
16
+ - new `Func3` type, that is function definition with three arguments and return type
17
+ - new `Func4` type, that is function definition with four arguments and return type
18
+ - new `Func5` type, that is function definition with five arguments and return type
19
+ - new `Action1` type, that is function definition with one argument and no return type
20
+ - new `Action2` type, that is function definition with two arguments and no return type
21
+ - new `Action3` type, that is function definition with three arguments and no return type
22
+ - new `Action4` type, that is function definition with four arguments and no return type
23
+ - new `Action5` type, that is function definition with five arguments and no return type
24
+ - new `Invalidatable` interface, that represents type that can be visualy invalidated
25
+ - **methods**
26
+ - `invalidateVisuals` - explicitly runs invalidation of content (change detection), which redraws contents
27
+ - new `WithSync` decorator, that adds special functionality to async method call, that allows only to call this method only when previous execution was finished
28
+ - updated `DebounceCall`, now asynchronously returns values, if call is canceled `undefined` is returned
29
+
30
+ ### BREAKING CHANGES
31
+
32
+ - dropped support of `Node.js` version `12`
33
+ - minimal supported version of `rxjs` is now `7.5.0`
34
+ - removed deprecated `toPromise` and replaced with `lastValueFrom`
35
+ - minimal supported version of `tslib` is now `2.4.0`
36
+ - removed redundant `resolvePromiseOr`, simple `await` is enough for `PromiseOr` value
37
+ - changed second parameter of `mapValuesToThis` to *nullable*, only change in typings
38
+
3
39
  ## Version 2.3.0 (2022-02-22)
4
40
 
5
41
  ### Features
@@ -1 +1 @@
1
- {"version":3,"file":"async.mjs","sourceRoot":"","sources":["../../../../rxjs/src/utils/async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAGhC;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAU,KAAmC;IAEnF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAEnC,IAAG,KAAK,YAAY,UAAU,EAC9B;YACI,KAAK,GAAG,KAAK;iBACR,SAAS,EAAE,CAAC;SACpB;QAED,IAAG,KAAK,YAAY,OAAO,EAC3B;YACI,KAAK;iBACA,IAAI,CAAC,OAAO,CAAC;iBACb,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAEnC,OAAO;SACV;QAED,OAAO,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {Observable} from 'rxjs';\nimport {PromiseObservableOr} from '../types/async';\n\n/**\n * Resolves `PromiseObservableOr` value, if value is Observable then can be completed without value and undefined is resolved\n * @param value - Value to be solved\n */\nexport function resolvePromiseObservableOr<TResult>(value: PromiseObservableOr<TResult>): Promise<TResult|undefined>\n{\n return new Promise((resolve, reject) =>\n {\n if(value instanceof Observable)\n {\n value = value\n .toPromise();\n }\n\n if(value instanceof Promise)\n {\n value\n .then(resolve)\n .catch(error => reject(error));\n\n return;\n }\n \n resolve(value);\n });\n}\n"]}
1
+ {"version":3,"file":"async.mjs","sourceRoot":"","sources":["../../../../rxjs/src/utils/async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,MAAM,CAAC;AAG3D;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAU,KAAmC;IAEnF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAEnC,IAAG,KAAK,YAAY,UAAU,EAC9B;YACI,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;SAChC;QAED,IAAG,KAAK,YAAY,OAAO,EAC3B;YACI,KAAK;iBACA,IAAI,CAAC,OAAO,CAAC;iBACb,KAAK,CAAC,KAAK,CAAC,EAAE;gBAEX,iDAAiD;gBACjD,IAAG,KAAK,YAAY,UAAU,EAC9B;oBACI,OAAO,CAAC,SAAS,CAAC,CAAC;oBAEnB,OAAO;iBACV;gBAED,MAAM,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;YAEP,OAAO;SACV;QAED,OAAO,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {EmptyError, lastValueFrom, Observable} from 'rxjs';\nimport {PromiseObservableOr} from '../types/async';\n\n/**\n * Resolves `PromiseObservableOr` value, if value is Observable then can be completed without value and undefined is resolved\n * @param value - Value to be solved\n */\nexport function resolvePromiseObservableOr<TResult>(value: PromiseObservableOr<TResult>): Promise<TResult|undefined>\n{\n return new Promise((resolve, reject) =>\n {\n if(value instanceof Observable)\n {\n value = lastValueFrom(value);\n }\n\n if(value instanceof Promise)\n {\n value\n .then(resolve)\n .catch(error =>\n {\n //handles observable that completes without value\n if(error instanceof EmptyError)\n {\n resolve(undefined);\n\n return;\n }\n\n reject(error);\n });\n\n return;\n }\n \n resolve(value);\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Observable } from 'rxjs';
1
+ import { EmptyError, lastValueFrom, Observable } from 'rxjs';
2
2
  /**
3
3
  * Resolves `PromiseObservableOr` value, if value is Observable then can be completed without value and undefined is resolved
4
4
  * @param value - Value to be solved
@@ -6,13 +6,19 @@ import { Observable } from 'rxjs';
6
6
  export function resolvePromiseObservableOr(value) {
7
7
  return new Promise((resolve, reject) => {
8
8
  if (value instanceof Observable) {
9
- value = value
10
- .toPromise();
9
+ value = lastValueFrom(value);
11
10
  }
12
11
  if (value instanceof Promise) {
13
12
  value
14
13
  .then(resolve)
15
- .catch(error => reject(error));
14
+ .catch(error => {
15
+ //handles observable that completes without value
16
+ if (error instanceof EmptyError) {
17
+ resolve(undefined);
18
+ return;
19
+ }
20
+ reject(error);
21
+ });
16
22
  return;
17
23
  }
18
24
  resolve(value);
@@ -1 +1 @@
1
- {"version":3,"file":"bindThis.decorator.mjs","sourceRoot":"","sources":["../../../src/decorators/bindThis.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,WAA0B,EAAE,UAA8B;;IAEhG,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,+CAAd,UAAU,CAAQ,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/functions';\r\nimport {isFunction} from '../utils/lang';\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<any, any>>\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}"]}
1
+ {"version":3,"file":"bindThis.decorator.mjs","sourceRoot":"","sources":["../../../src/decorators/bindThis.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,WAA0B,EAAE,UAA8B;;IAEhG,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,0DAAI,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/functions';\r\nimport {isFunction} from '../utils/lang';\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<any, any>>\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}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"callOnce.decorator.mjs","sourceRoot":"","sources":["../../../src/decorators/callOnce.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IAEjC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;;QAEvF,IAAI,OAAoB,CAAC;QACzB,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,+CAAd,UAAU,CAAQ,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/functions';\r\nimport {isFunction, isPresent} from '../utils/lang';\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}"]}
1
+ {"version":3,"file":"callOnce.decorator.mjs","sourceRoot":"","sources":["../../../src/decorators/callOnce.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IAEjC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;;QAEvF,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACnC,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,0DAAI,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,UAA6C,GAAG,IAAe;YAE9E,IAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAC3B;gBACI,OAAO;aACV;YAED,kCAAkC;YAClC,IAAG,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,EACrB;gBACI,OAAO,CAAC,cAAc,CAAC,IAAI,EACJ,OAAO,EACP;oBACI,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,IAAI;iBACd,CAAC,CAAC;aAC7B;YAED,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEhC,IAAI,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE;gBAE5B,IAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAC3B;oBACI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;iBAC/B;gBAED,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;YACzB,CAAC,EAAE,IAAI,CAAQ,CAAC;QACpB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {Func} from '../types/functions';\r\nimport {isFunction, isPresent} from '../utils/lang';\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 const timeout = Symbol('ɵTimeout');\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(this: {[key: symbol]: number|null}, ...args: unknown[]): void\r\n {\r\n if(isPresent(this[timeout]))\r\n {\r\n return;\r\n }\r\n \r\n //timeout variable does not exists\r\n if(!(timeout in this))\r\n {\r\n Reflect.defineProperty(this,\r\n timeout,\r\n {\r\n writable: true,\r\n value: null,\r\n });\r\n }\r\n\r\n originalValue.apply(this, args);\r\n\r\n this[timeout] = setTimeout(() =>\r\n {\r\n if(isPresent(this[timeout]))\r\n {\r\n clearTimeout(this[timeout]);\r\n }\r\n \r\n this[timeout] = null;\r\n }, time) as any;\r\n };\r\n\r\n return descriptor;\r\n };\r\n}"]}
@@ -6,21 +6,28 @@ import { isFunction, isPresent } from '../utils/lang.mjs';
6
6
  export function CallOnce(time) {
7
7
  return function (_target, propertyKey, descriptor) {
8
8
  var _a, _b;
9
- let timeout;
9
+ const timeout = Symbol('ɵTimeout');
10
10
  const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
11
11
  if (!isFunction(originalValue)) {
12
12
  throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey.toString()}', it is not a method.`);
13
13
  }
14
14
  descriptor.value = function (...args) {
15
- if (isPresent(timeout)) {
15
+ if (isPresent(this[timeout])) {
16
16
  return;
17
17
  }
18
+ //timeout variable does not exists
19
+ if (!(timeout in this)) {
20
+ Reflect.defineProperty(this, timeout, {
21
+ writable: true,
22
+ value: null,
23
+ });
24
+ }
18
25
  originalValue.apply(this, args);
19
- timeout = setTimeout(() => {
20
- if (isPresent(timeout)) {
21
- clearTimeout(timeout);
26
+ this[timeout] = setTimeout(() => {
27
+ if (isPresent(this[timeout])) {
28
+ clearTimeout(this[timeout]);
22
29
  }
23
- timeout = null;
30
+ this[timeout] = null;
24
31
  }, time);
25
32
  };
26
33
  return descriptor;
@@ -1 +1 @@
1
- {"version":3,"file":"debounceCall.decorator.mjs","sourceRoot":"","sources":["../../../src/decorators/debounceCall.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IAEtC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;;QAEvF,IAAI,OAAe,CAAC;QACpB,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,+CAAd,UAAU,CAAQ,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/functions';\r\nimport {isFunction, isPresent} from '../utils/lang';\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}"]}
1
+ {"version":3,"file":"debounceCall.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AAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAE5B,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,OAAO,CAAoB,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;aACzF;YAED,kCAAkC;YAClC,IAAG,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,EACrB;gBACI,OAAO,CAAC,cAAc,CAAC,IAAI,EACJ,OAAO,EACP;oBACI,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,IAAI;iBACd,CAAC,CAAC;aAC7B;YAED,IAAI,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,GAAS,EAAE;gBAElC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,aAAa,CAAC,KAAK,CAA+B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBACnF,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,OAAO,CAAoB,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;gBACtF,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;YACzB,CAAC,CAAA,EAAE,KAAK,CAAQ,CAAC;YAEjB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {PromiseOr} from '../types/async';\r\nimport {Action1, Func} from '../types/functions';\r\nimport {isFunction, isPresent} from '../utils/lang';\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 const timeout = Symbol('ɵTimeout');\r\n const resolve = Symbol('ɵResolve');\r\n const result = Symbol('ɵResult');\r\n const originalValue: Func<any> = 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<TResult>(this: {[timeout]: number|null, [resolve]: Action1<TResult|undefined>, [result]: Promise<TResult|undefined>}, ...args: unknown[]): Promise<TResult|undefined>\r\n {\r\n //result variable does not exists\r\n if(!(resolve in this) && !(result in this))\r\n {\r\n let resolveFn: Action1<TResult|undefined>|undefined;\r\n const promise = new Promise<TResult|undefined>(resolve => resolveFn = resolve);\r\n\r\n Reflect.defineProperty(this,\r\n resolve,\r\n {\r\n writable: true,\r\n value: resolveFn,\r\n });\r\n\r\n Reflect.defineProperty(this,\r\n result,\r\n {\r\n writable: true,\r\n value: promise,\r\n });\r\n }\r\n\r\n \r\n\r\n if(isPresent(this[timeout]))\r\n {\r\n clearTimeout(this[timeout]);\r\n\r\n this[resolve](undefined);\r\n this[result] = new Promise<TResult|undefined>(resolveFn => this[resolve] = resolveFn);\r\n }\r\n\r\n //timeout variable does not exists\r\n if(!(timeout in this))\r\n {\r\n Reflect.defineProperty(this,\r\n timeout,\r\n {\r\n writable: true,\r\n value: null,\r\n });\r\n }\r\n\r\n this[timeout] = setTimeout(async () =>\r\n {\r\n this[resolve](await originalValue.apply<any, any, PromiseOr<TResult>>(this, args));\r\n this[result] = new Promise<TResult|undefined>(resolveFn => this[resolve] = resolveFn);\r\n this[timeout] = null;\r\n }, delay) as any;\r\n\r\n return this[result];\r\n };\r\n\r\n return descriptor;\r\n };\r\n}"]}
@@ -1,3 +1,4 @@
1
+ import { __awaiter } from "tslib";
1
2
  import { isFunction, isPresent } from '../utils/lang.mjs';
2
3
  /**
3
4
  * Adds special functionality to method call, that debounce method call for specified time
@@ -6,18 +7,45 @@ import { isFunction, isPresent } from '../utils/lang.mjs';
6
7
  export function DebounceCall(delay) {
7
8
  return function (_target, propertyKey, descriptor) {
8
9
  var _a, _b;
9
- let timeout;
10
+ const timeout = Symbol('ɵTimeout');
11
+ const resolve = Symbol('ɵResolve');
12
+ const result = Symbol('ɵResult');
10
13
  const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
11
14
  if (!isFunction(originalValue)) {
12
15
  throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey.toString()}', it is not a method.`);
13
16
  }
14
17
  descriptor.value = function (...args) {
15
- if (isPresent(timeout)) {
16
- clearTimeout(timeout);
18
+ //result variable does not exists
19
+ if (!(resolve in this) && !(result in this)) {
20
+ let resolveFn;
21
+ const promise = new Promise(resolve => resolveFn = resolve);
22
+ Reflect.defineProperty(this, resolve, {
23
+ writable: true,
24
+ value: resolveFn,
25
+ });
26
+ Reflect.defineProperty(this, result, {
27
+ writable: true,
28
+ value: promise,
29
+ });
17
30
  }
18
- timeout = setTimeout(() => {
19
- originalValue.apply(this, args);
20
- }, delay);
31
+ if (isPresent(this[timeout])) {
32
+ clearTimeout(this[timeout]);
33
+ this[resolve](undefined);
34
+ this[result] = new Promise(resolveFn => this[resolve] = resolveFn);
35
+ }
36
+ //timeout variable does not exists
37
+ if (!(timeout in this)) {
38
+ Reflect.defineProperty(this, timeout, {
39
+ writable: true,
40
+ value: null,
41
+ });
42
+ }
43
+ this[timeout] = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
44
+ this[resolve](yield originalValue.apply(this, args));
45
+ this[result] = new Promise(resolveFn => this[resolve] = resolveFn);
46
+ this[timeout] = null;
47
+ }), delay);
48
+ return this[result];
21
49
  };
22
50
  return descriptor;
23
51
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withSync.decorator.mjs","sourceRoot":"","sources":["../../../src/decorators/withSync.decorator.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,QAAQ;IAEpB,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;;QAEvF,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,0DAAI,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,UAAqD,GAAG,IAAe;;gBAEtF,+BAA+B;gBAC/B,IAAG,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,EAClB;oBACI,OAAO,CAAC,cAAc,CAAC,IAAI,EACJ,IAAI,EACJ;wBACI,QAAQ,EAAE,IAAI;wBACd,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE;qBAC3B,CAAC,CAAC;iBAC7B;gBAED,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;gBACjB,IAAI,WAAiC,CAAC;gBACtC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC;gBAE3D,MAAM,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAEtC,WAAW,aAAX,WAAW,uBAAX,WAAW,EAAI,CAAC;YACpB,CAAC;SAAA,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {Func, NoopAction} from '../types/functions';\nimport {isFunction} from '../utils/lang';\n\n/**\n * Adds special functionality to async method call, that allows only to call this method only when previous execution was finished\n */\nexport function WithSync(): MethodDecorator\n{\n return function(_target: Object, propertyKey: string|symbol, descriptor: PropertyDescriptor)\n {\n const sync = Symbol('ɵSync');\n const originalValue: Func = descriptor.value ?? descriptor.get?.();\n\n if(!isFunction(originalValue))\n {\n throw new Error(`Unable to apply @WithSync() decorator to '${propertyKey.toString()}', it is not a method.`);\n }\n\n descriptor.value = async function(this: {[key: symbol]: Promise<void>}, ...args: unknown[]): Promise<void>\n {\n //sync variable does not exists\n if(!(sync in this))\n {\n Reflect.defineProperty(this,\n sync,\n {\n writable: true,\n value: Promise.resolve(),\n });\n }\n\n await this[sync];\n let syncResolve: NoopAction|undefined;\n this[sync] = new Promise(resolve => syncResolve = resolve);\n\n await originalValue.apply(this, args);\n\n syncResolve?.();\n };\n\n return descriptor;\n };\n}"]}
@@ -0,0 +1,33 @@
1
+ import { __awaiter } from "tslib";
2
+ import { isFunction } from '../utils/lang.mjs';
3
+ /**
4
+ * Adds special functionality to async method call, that allows only to call this method only when previous execution was finished
5
+ */
6
+ export function WithSync() {
7
+ return function (_target, propertyKey, descriptor) {
8
+ var _a, _b;
9
+ const sync = Symbol('ɵSync');
10
+ const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
11
+ if (!isFunction(originalValue)) {
12
+ throw new Error(`Unable to apply @WithSync() decorator to '${propertyKey.toString()}', it is not a method.`);
13
+ }
14
+ descriptor.value = function (...args) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ //sync variable does not exists
17
+ if (!(sync in this)) {
18
+ Reflect.defineProperty(this, sync, {
19
+ writable: true,
20
+ value: Promise.resolve(),
21
+ });
22
+ }
23
+ yield this[sync];
24
+ let syncResolve;
25
+ this[sync] = new Promise(resolve => syncResolve = resolve);
26
+ yield originalValue.apply(this, args);
27
+ syncResolve === null || syncResolve === void 0 ? void 0 : syncResolve();
28
+ });
29
+ };
30
+ return descriptor;
31
+ };
32
+ }
33
+ //# sourceMappingURL=withSync.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,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;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC","sourcesContent":["import {globalDefine} from './jsDevMode';\r\nimport {isBlank} from './utils/lang';\r\n\r\nglobalDefine(global =>\r\n{\r\n if(isBlank(global['jsDevMode']))\r\n {\r\n global['jsDevMode'] = false;\r\n }\r\n});\r\n\r\nexport * from './jsDevMode';\r\nexport * from './encoder/encoder';\r\nexport * from './paginator/paginator';\r\nexport * from './normalizer/charMaps';\r\nexport * from './normalizer/normalizer';\r\nexport * from './enums/orderByDirection';\r\nexport * from './types/async';\r\nexport * from './types/cssProperties';\r\nexport * from './types/dictionaries';\r\nexport * from './types/enums';\r\nexport * from './types/functions';\r\nexport * from './types/pageable';\r\nexport * from './types/pagedData';\r\nexport * from './types/valueNamePair';\r\nexport * from './utils/async';\r\nexport * from './utils/common';\r\nexport * from './utils/lang';\r\nexport * from './utils/nameof';\r\nexport * from './decorators/bindThis.decorator';\r\nexport * from './decorators/callOnce.decorator';\r\nexport * from './decorators/debounceCall.decorator';\r\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,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;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC","sourcesContent":["import {globalDefine} from './jsDevMode';\r\nimport {isBlank} from './utils/lang';\r\n\r\nglobalDefine(global =>\r\n{\r\n if(isBlank(global['jsDevMode']))\r\n {\r\n global['jsDevMode'] = false;\r\n }\r\n});\r\n\r\nexport * from './jsDevMode';\r\nexport * from './encoder/encoder';\r\nexport * from './paginator/paginator';\r\nexport * from './normalizer/charMaps';\r\nexport * from './normalizer/normalizer';\r\nexport * from './enums/orderByDirection';\r\nexport * from './types/async';\r\nexport * from './types/cssProperties';\r\nexport * from './types/dictionaries';\r\nexport * from './types/enums';\r\nexport * from './types/functions';\r\nexport * from './types/invalidatable';\r\nexport * from './types/pageable';\r\nexport * from './types/pagedData';\r\nexport * from './types/valueNamePair';\r\nexport * from './utils/common';\r\nexport * from './utils/lang';\r\nexport * from './utils/nameof';\r\nexport * from './decorators/bindThis.decorator';\r\nexport * from './decorators/callOnce.decorator';\r\nexport * from './decorators/debounceCall.decorator';\r\nexport * from './decorators/withSync.decorator';\r\n"]}
package/es/src/index.mjs CHANGED
@@ -16,14 +16,15 @@ export * from './types/cssProperties.mjs';
16
16
  export * from './types/dictionaries.mjs';
17
17
  export * from './types/enums.mjs';
18
18
  export * from './types/functions.mjs';
19
+ export * from './types/invalidatable.mjs';
19
20
  export * from './types/pageable.mjs';
20
21
  export * from './types/pagedData.mjs';
21
22
  export * from './types/valueNamePair.mjs';
22
- export * from './utils/async.mjs';
23
23
  export * from './utils/common.mjs';
24
24
  export * from './utils/lang.mjs';
25
25
  export * from './utils/nameof.mjs';
26
26
  export * from './decorators/bindThis.decorator.mjs';
27
27
  export * from './decorators/callOnce.decorator.mjs';
28
28
  export * from './decorators/debounceCall.decorator.mjs';
29
+ export * from './decorators/withSync.decorator.mjs';
29
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dictionaries.mjs","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 type that extracts class as type Record with property keys as index and any property values\r\n */\r\nexport type AsAnyDictionary<TType extends Object> = TType extends {[P in keyof TType]: any} ? Record<keyof TType, any> : any;\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>;\r\n"]}
1
+ {"version":3,"file":"dictionaries.mjs","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 any> = TType extends {[P in keyof TType]: unknown} ? Record<keyof TType, unknown> : unknown;\r\n\r\n/**\r\n * Represents type that extracts class as type Record with property keys as index and any property values\r\n */\r\nexport type AsAnyDictionary<TType extends any> = TType extends {[P in keyof TType]: any} ? Record<keyof TType, any> : any;\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>;\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"functions.mjs","sourceRoot":"","sources":["../../../src/types/functions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Type that extracts function signature from function type\n */\nexport type FuncSignature<TResult extends (...args: any) => any> = TResult extends (...args: infer P) => infer R ? (...args: P) => R : never;\n\n/**\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 * @typeParam TArgs - Type parameters for function\n */\nexport type Action<TArgs extends Array<unknown> = unknown[]> = (...args: TArgs) => void;\n\n/**\n * Function definition with variable arguments and return type\n * @typeParam TResult - Return type of function\n * @typeParam TArgs - Type parameters for function\n */\nexport type Func<TResult = unknown, TArgs extends Array<unknown> = unknown[]> = (...args: TArgs) => TResult;\n"]}
1
+ {"version":3,"file":"functions.mjs","sourceRoot":"","sources":["../../../src/types/functions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Type that extracts function signature from function type\n */\nexport type FuncSignature<TResult extends (...args: any) => any> = TResult extends (...args: infer P) => infer R ? (...args: P) => R : never;\n\n/**\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 * @typeParam TArgs - Type parameters for function\n */\nexport type Action<TArgs extends Array<unknown> = unknown[]> = (...args: TArgs) => void;\n\n/**\n * Function definition with one argument and no return type\n * @typeParam TArg1 - Type of first parameter\n */\nexport type Action1<TArg1 = unknown> = (arg1: TArg1) => void;\n\n/**\n * Function definition with two arguments and no return type\n * @typeParam TArg1 - Type of first parameter\n * @typeParam TArg2 - Type of second parameter\n */\nexport type Action2<TArg1 = unknown, TArg2 = unknown> = (arg1: TArg1, arg2: TArg2) => void;\n\n/**\n * Function definition with three arguments and no return type\n * @typeParam TArg1 - Type of first parameter\n * @typeParam TArg2 - Type of second parameter\n * @typeParam TArg3 - Type of third parameter\n */\nexport type Action3<TArg1 = unknown, TArg2 = unknown, TArg3 = unknown> = (arg1: TArg1, arg2: TArg2, arg3: TArg3) => void;\n\n/**\n * Function definition with four arguments and no return type\n * @typeParam TArg1 - Type of first parameter\n * @typeParam TArg2 - Type of second parameter\n * @typeParam TArg3 - Type of third parameter\n * @typeParam TArg4 - Type of fourth parameter\n */\nexport type Action4<TArg1 = unknown, TArg2 = unknown, TArg3 = unknown, TArg4 = unknown> = (arg1: TArg1, arg2: TArg2, arg3: TArg3, arg4: TArg4) => void;\n\n/**\n * Function definition with five arguments and no return type\n * @typeParam TArg1 - Type of first parameter\n * @typeParam TArg2 - Type of second parameter\n * @typeParam TArg3 - Type of third parameter\n * @typeParam TArg4 - Type of fourth parameter\n * @typeParam TArg5 - Type of fifth parameter\n */\nexport type Action5<TArg1 = unknown, TArg2 = unknown, TArg3 = unknown, TArg4 = unknown, TArg5 = unknown> = (arg1: TArg1, arg2: TArg2, arg3: TArg3, arg4: TArg4, arg5: TArg5) => void;\n\n/**\n * Function definition with variable arguments and return type\n * @typeParam TResult - Return type of function\n * @typeParam TArgs - Type parameters for function\n */\nexport type Func<TResult = unknown, TArgs extends Array<unknown> = unknown[]> = (...args: TArgs) => TResult;\n\n/**\n * Function definition with one argument and return type\n * @typeParam TResult - Return type of function\n * @typeParam TArg1 - Type of first parameter\n */\nexport type Func1<TResult = unknown, TArg1 = unknown> = (arg1: TArg1) => TResult;\n\n/**\n * Function definition with two arguments and return type\n * @typeParam TResult - Return type of function\n * @typeParam TArg1 - Type of first parameter\n * @typeParam TArg2 - Type of second parameter\n */\nexport type Func2<TResult = unknown, TArg1 = unknown, TArg2 = unknown> = (arg1: TArg1, arg2: TArg2) => TResult;\n\n/**\n * Function definition with three arguments and return type\n * @typeParam TResult - Return type of function\n * @typeParam TArg1 - Type of first parameter\n * @typeParam TArg2 - Type of second parameter\n * @typeParam TArg3 - Type of third parameter\n */\nexport type Func3<TResult = unknown, TArg1 = unknown, TArg2 = unknown, TArg3 = unknown> = (arg1: TArg1, arg2: TArg2, arg3: TArg3) => TResult;\n\n/**\n * Function definition with four arguments and return type\n * @typeParam TResult - Return type of function\n * @typeParam TArg1 - Type of first parameter\n * @typeParam TArg2 - Type of second parameter\n * @typeParam TArg3 - Type of third parameter\n * @typeParam TArg4 - Type of fourth parameter\n */\nexport type Func4<TResult = unknown, TArg1 = unknown, TArg2 = unknown, TArg3 = unknown, TArg4 = unknown> = (arg1: TArg1, arg2: TArg2, arg3: TArg3, arg4: TArg4) => TResult;\n\n/**\n * Function definition with five arguments and return type\n * @typeParam TResult - Return type of function\n * @typeParam TArg1 - Type of first parameter\n * @typeParam TArg2 - Type of second parameter\n * @typeParam TArg3 - Type of third parameter\n * @typeParam TArg4 - Type of fourth parameter\n * @typeParam TArg5 - Type of fifth parameter\n */\nexport type Func5<TResult = unknown, TArg1 = unknown, TArg2 = unknown, TArg3 = unknown, TArg4 = unknown, TArg5 = unknown> = (arg1: TArg1, arg2: TArg2, arg3: TArg3, arg4: TArg4, arg5: TArg5) => TResult;\n\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidatable.mjs","sourceRoot":"","sources":["../../../src/types/invalidatable.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents type that can be visualy invalidated\n */\nexport interface Invalidatable\n{\n //######################### methods #########################\n\n /**\n * Explicitly runs invalidation of content (change detection), which redraws contents\n */\n invalidateVisuals(): void;\n}"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=invalidatable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.mjs","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AAIjC,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IAErC,OAAO,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5C,CAAC;AAyED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,YAAuC,EAAE,GAAG,OAA0B;IAEzF,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IAErC,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAC9B;QACI,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EA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AAC,GAAG,EAAE,CAAC,GAAI,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,EAAE,CAAC,CAAC;QAE/C,UAAU,CAAC,GAAG,EAAE;YAEZ,IAAG,GAAG,EACN;gBACI,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;gBAExB,UAAU,CAAC,GAAG,EAAE;oBAEZ,GAAI,CAAC,MAAM,EAAE,CAAC;oBACd,GAAG,GAAG,IAAI,CAAC;gBACf,CAAC,EAAE,GAAG,CAAC,CAAC;aACX;QACL,CAAC,EAAE,IAAI,CAAC,CAAC;KACZ;AACL,CAAC","sourcesContent":["import extendLib from 'extend';\r\n\r\nimport {isPresent} from './lang';\r\nimport {AsDictionary, Dictionary, StringDictionary} from '../types/dictionaries';\r\nimport {Enum} from '../types/enums';\r\nimport {ValueNamePair} from '../types/valueNamePair';\r\nimport {normalize} from '../normalizer/normalizer';\r\n\r\n/**\r\n * Reverse current string and returns new reverse string\r\n * @param str - String to be reversed\r\n * @returns string Reverse string\r\n */\r\nexport function reverseString(str: string): string\r\n{\r\n return str.split('').reverse().join('');\r\n}\r\n\r\n/**\r\n * Extends target object with source\r\n * @param deep - Indication whether deep copy should be performed\r\n * @param target - Object that will extended\r\n * @param source - Object that will be used for extending\r\n */\r\nexport function extend<T, U>(deep: boolean, target: T, source: U): T & U;\r\n/**\r\n * Extends target object with source objects\r\n * @param deep - Indication whether deep copy should be performed\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V>(deep: boolean, target: T, source1: U, source2: V): T & U & V;\r\n/**\r\n * Extends target object with source objects\r\n * @param deep - Indication whether deep copy should be performed\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n * @param source3 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V, W>(deep: boolean, target: T, source1: U, source2: V, source3: W): T & U & V & W;\r\n/**\r\n * Extends target object with source objects\r\n * @param deep - Indication whether deep copy should be performed\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n * @param source3 - Object that will be used for extending\r\n * @param source4 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V, W, X>(deep: boolean, target: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X;\r\n/**\r\n * Extends target object with source\r\n * @param target - Object that will extended\r\n * @param source - Object that will be used for extending\r\n */\r\nexport function extend<T, U>(target: T, source: U): T & U;\r\n/**\r\n * Extends target object with source\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V>(target: T, source1: U, source2: V): T & U & V;\r\n/**\r\n * Extends target object with source\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n * @param source3 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;\r\n/**\r\n * Extends target object with source\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n * @param source3 - Object that will be used for extending\r\n * @param source4 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V, W, X>(target: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X;\r\n/**\r\n * Extends one object with additional properties from other objects, supports deep extend\r\n * @param deepOrObject - Object to be extended or indication that deep copy should be performed\r\n * @param objectN - Objects that will be used for extending, if deep is used first here is target object\r\n * @returns Object Extended object with properties from other objects\r\n */\r\nexport function extend<TResult>(deepOrObject: boolean | Dictionary<any>, ...objectN: Dictionary<any>[]): TResult;\r\n/**\r\n * Extends one object with additional properties from other objects, supports deep extend\r\n * @param deepOrObject - Object to be extended or indication that deep copy should be performed\r\n * @param objectN - Objects that will be used for extending, if deep is used first here is target object\r\n * @returns Object Extended object with properties from other objects\r\n */\r\nexport function extend(deepOrObject: boolean | Dictionary<any>, ...objectN: Dictionary<any>[]): Dictionary\r\n{\r\n return extendLib.apply(null, [deepOrObject, ...objectN]);\r\n}\r\n\r\n/**\r\n * Generates random string consisting from lowercase letters\r\n * @param length - Length of generated string\r\n * @returns number Generated string\r\n */\r\nexport function generateId(length: number): string\r\n{\r\n let result = '';\r\n\r\n for(let x = 0; x < length; x++)\r\n {\r\n result += String.fromCharCode(Math.round(Math.random() * 25 + 97));\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Generates random string of specified length from possible characters\r\n * @param length - Length of generated string\r\n * @param possible - Possible characters used for generation of string\r\n */\r\nexport function generateRandomString(length: number, possible: string = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'): string\r\n{\r\n let text = '';\r\n\r\n for (let i = 0;i < length; i++)\r\n {\r\n text += possible.charAt(Math.floor(Math.random() * possible.length));\r\n }\r\n\r\n return text;\r\n}\r\n\r\n/**\r\n * Converts string in that way that first letter will be lowerCase\r\n * @param text - Text to be converted\r\n */\r\nexport function firstToLowerCase(text: string): string\r\n{\r\n return text.charAt(0).toLowerCase() + text.substr(1);\r\n}\r\n\r\n/**\r\n * Gets indication whether is child descendand of parent\r\n * @param parent - Parent to be tested\r\n * @param child - Child to be looked for\r\n */\r\nexport function isDescendant(parent: HTMLElement, child: HTMLElement): boolean\r\n{\r\n let node = child.parentNode;\r\n\r\n while (node != null)\r\n {\r\n if (node == parent)\r\n {\r\n return true;\r\n }\r\n\r\n node = node.parentNode;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Computes offset of element against document\r\n * @param element - Html element which offset is counted\r\n * @param doc - Html document to be used for extracting scroll offset\r\n */\r\nexport function offset(element: HTMLElement, doc?: Document)\r\n{\r\n doc = doc || document;\r\n\r\n const rect = element.getBoundingClientRect(),\r\n scrollLeft = window.pageXOffset || doc.documentElement.scrollLeft,\r\n scrollTop = window.pageYOffset || doc.documentElement.scrollTop;\r\n\r\n return {\r\n top: rect.top + scrollTop,\r\n left: rect.left + scrollLeft,\r\n bottom: rect.top + scrollTop + rect.height,\r\n right: rect.left + scrollLeft + rect.width\r\n };\r\n}\r\n\r\n/**\r\n * Converts html string into html DOM\r\n * @param html - Html string to be converted to DOM\r\n * @param doc - Optional html document to be used\r\n */\r\nexport function htmlToElement(html: string, doc?: Document): HTMLElement\r\n{\r\n let htmlDocument = document;\r\n\r\n if(isPresent(doc))\r\n {\r\n htmlDocument = doc;\r\n }\r\n\r\n const template = htmlDocument.createElement('template');\r\n html = html.trim();\r\n template.innerHTML = html;\r\n\r\n return template.content.firstChild as HTMLElement;\r\n}\r\n\r\n/**\r\n * Extract values from enum type\r\n * @param enumType - Enum type that will have extracted values\r\n */\r\nexport function getEnumValues<TEnum extends Enum>(enumType: TEnum): ValueNamePair[]\r\n{\r\n const result: ValueNamePair[] = [];\r\n\r\n Object.keys(enumType).forEach(key =>\r\n {\r\n if(isNaN(+key))\r\n {\r\n return;\r\n }\r\n\r\n result.push(\r\n {\r\n value: key,\r\n name: enumType[+key]\r\n });\r\n });\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Safely returns value from object property using string expression\r\n * @param object - Object which property value will be obtained\r\n * @param expression - Expression for obtaining value\r\n */\r\nexport function getValue<TValue = unknown>(object: Dictionary<any>, expression: string): TValue\r\nexport function getValue(object: Dictionary<any>, expression: string): unknown\r\n{\r\n return expression.split('.').reduce((o, i) =>\r\n {\r\n if(o)\r\n {\r\n return o[i];\r\n }\r\n\r\n return null;\r\n }, object);\r\n}\r\n\r\n/**\r\n * Sets value to objects property using string expression\r\n * @param object - Object which property value will be set\r\n * @param value - Value that will be set\r\n * @param expression - Expression for setting value\r\n */\r\nexport function setValue(object: Dictionary<any>, value: unknown, expression: string): void\r\n{\r\n const parts = expression.split('.');\r\n\r\n parts.forEach((part, index) =>\r\n {\r\n //last item value is assigned\r\n if(index == parts.length - 1)\r\n {\r\n if(isPresent(value))\r\n {\r\n object[part] = value;\r\n }\r\n\r\n return;\r\n }\r\n\r\n object = object[part] = object[part] ?? {};\r\n });\r\n}\r\n\r\n/**\r\n * Formats string using '%s', to print '%s' you have to use '%%s'\r\n * @param str - String containing substitution constants\r\n * @param args - Arguments that are used for replacement\r\n */\r\nexport function format(str: string, ...args: unknown[]): string\r\n{\r\n let i = 0;\r\n\r\n return str.replace(/((?!%).)%s/g, (_sub, substArgs) => `${substArgs[0]}${args[i++]}`).replace(/%%s/g, '%s');\r\n}\r\n\r\n/**\r\n * Performs flatMap over provided array\r\n * @param array - Array to be reduced using flatMap\r\n */\r\nexport function flatMapArray<TItem>(array: TItem[][]): TItem[]\r\n{\r\n return array.reduce((acc, x) => acc.concat(x), []);\r\n}\r\n\r\n/**\r\n * Serialize object to string that is usable as url query parameter\r\n * @param obj - Object to be serialized\r\n * @param replacer - Function that can be used for replacing provided values\r\n */\r\nexport function serializeToUrlQuery<TObj>(obj: TObj, replacer?: (this: any, key: string, value: any) => any): string\r\n{\r\n return btoa(encodeURIComponent(JSON.stringify(obj, replacer)));\r\n}\r\n\r\n/**\r\n * Deserialize value from url query string into object\r\n * @param queryParamValue - Query param string value\r\n * @param reviver - Function that can be used for correctly deserializing value\r\n */\r\nexport function deserializeFromUrlQuery<TObj>(queryParamValue: string, reviver?: (this: any, key: string, value: any) => any): TObj\r\n{\r\n return JSON.parse(decodeURIComponent(atob(queryParamValue)), reviver);\r\n}\r\n\r\n/**\r\n * Converts id to valid html id\r\n * @param id - Id that is going to be converted to valid html id\r\n * @param charMap - Character map used during normalization\r\n */\r\nexport function validHtmlId(id: string, charMap: StringDictionary = {}): string\r\n{\r\n id = id.toLowerCase()\r\n .replace(/[\\s]+/g, '-')\r\n .replace(/\\./g, '')\r\n .replace(/^(\\d)/g, 'x$1');\r\n\r\n id = normalize(id, charMap);\r\n\r\n return id;\r\n}\r\n\r\n/**\r\n * Checks whether is element overflown either horizontal, or vertical\r\n * @param element - Element to be tested for overflow\r\n */\r\nexport function isOverflown(element: HTMLElement): boolean\r\n{\r\n return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;\r\n}\r\n\r\n/**\r\n * Normalizes string, removing accent\r\n * @param value - String to be normalized\r\n */\r\nexport function normalizeAccent(value: string): string\r\n{\r\n return value.normalize('NFD').replace(/[\\u0300-\\u036f]/g, '');\r\n}\r\n\r\n/**\r\n * Converts instance of Class to equivalent Record type\r\n * @param instance - Instance which type to be converted\r\n * @typeparam TType - Type of instance\r\n */\r\nexport function asDictionary<TType>(instance: TType): AsDictionary<TType>\r\n{\r\n return instance as AsDictionary<TType>;\r\n}\r\n\r\n/**\r\n * Maps all iterable property values of object to \"this\" bounded\r\n * @param this - Object which will be filled with new values\r\n * @param value - Object holding values that will be used for filling\r\n * @param all - Indication whether map only existing properties or everything\r\n */\r\nexport function mapValuesToThis(this: Dictionary<any>, value: Dictionary<any>, all: boolean = false): void\r\n{\r\n if(!value)\r\n {\r\n return;\r\n }\r\n\r\n Object.keys(value).forEach(prop =>\r\n {\r\n if(value[prop] !== undefined && (all || (prop in this)))\r\n {\r\n this[prop] = value[prop];\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Briefly shows simple notification with simple text\r\n * @param show - Indication whether show notification\r\n * @param text - Text to be displayed, defaults to HMR finished text\r\n */\r\nexport function simpleNotification(show: boolean, text: string = 'HMR finished, app updated!'): void\r\n{\r\n if (show)\r\n {\r\n let div: HTMLDivElement|null = document.createElement('div');\r\n div.style.position = 'absolute';\r\n div.style.zIndex = '54345';\r\n div.style.background = 'rgb(255, 255, 255) none repeat scroll 0% 0%';\r\n div.style.padding = '8px';\r\n div.style.fontWeight = 'bold';\r\n div.style.borderRadius = 'bold';\r\n div.style.color = 'rgb(21, 57, 255)';\r\n div.style.left = '47%';\r\n div.style.top = '11px';\r\n div.style.boxShadow = '0px 0px 4px rgb(170, 170, 170)';\r\n div.style.transition = 'all 500ms';\r\n div.style.opacity = '0';\r\n\r\n div.innerText = text;\r\n\r\n document.body.append(div);\r\n\r\n setTimeout(() => div!.style.opacity = '1', 50);\r\n\r\n setTimeout(() =>\r\n {\r\n if(div)\r\n {\r\n div.style.opacity = '0';\r\n\r\n setTimeout(() =>\r\n {\r\n div!.remove();\r\n div = null;\r\n }, 500);\r\n }\r\n }, 2000);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"common.mjs","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AAIjC,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IAErC,OAAO,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5C,CAAC;AAyED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,YAAuC,EAAE,GAAG,OAA0B;IAEzF,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IAErC,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAC9B;QACI,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;KACtE;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,WAAmB,gEAAgE;IAEpI,IAAI,IAAI,GAAG,EAAE,CAAC;IAEd,KAAK,IAAI,CAAC,GAA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AExB,UAAU,CAAC,GAAG,EAAE;oBAEZ,GAAI,CAAC,MAAM,EAAE,CAAC;oBACd,GAAG,GAAG,IAAI,CAAC;gBACf,CAAC,EAAE,GAAG,CAAC,CAAC;aACX;QACL,CAAC,EAAE,IAAI,CAAC,CAAC;KACZ;AACL,CAAC","sourcesContent":["import extendLib from 'extend';\r\n\r\nimport {isPresent} from './lang';\r\nimport {AsDictionary, Dictionary, StringDictionary} from '../types/dictionaries';\r\nimport {Enum} from '../types/enums';\r\nimport {ValueNamePair} from '../types/valueNamePair';\r\nimport {normalize} from '../normalizer/normalizer';\r\n\r\n/**\r\n * Reverse current string and returns new reverse string\r\n * @param str - String to be reversed\r\n * @returns string Reverse string\r\n */\r\nexport function reverseString(str: string): string\r\n{\r\n return str.split('').reverse().join('');\r\n}\r\n\r\n/**\r\n * Extends target object with source\r\n * @param deep - Indication whether deep copy should be performed\r\n * @param target - Object that will extended\r\n * @param source - Object that will be used for extending\r\n */\r\nexport function extend<T, U>(deep: boolean, target: T, source: U): T & U;\r\n/**\r\n * Extends target object with source objects\r\n * @param deep - Indication whether deep copy should be performed\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V>(deep: boolean, target: T, source1: U, source2: V): T & U & V;\r\n/**\r\n * Extends target object with source objects\r\n * @param deep - Indication whether deep copy should be performed\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n * @param source3 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V, W>(deep: boolean, target: T, source1: U, source2: V, source3: W): T & U & V & W;\r\n/**\r\n * Extends target object with source objects\r\n * @param deep - Indication whether deep copy should be performed\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n * @param source3 - Object that will be used for extending\r\n * @param source4 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V, W, X>(deep: boolean, target: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X;\r\n/**\r\n * Extends target object with source\r\n * @param target - Object that will extended\r\n * @param source - Object that will be used for extending\r\n */\r\nexport function extend<T, U>(target: T, source: U): T & U;\r\n/**\r\n * Extends target object with source\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V>(target: T, source1: U, source2: V): T & U & V;\r\n/**\r\n * Extends target object with source\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n * @param source3 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;\r\n/**\r\n * Extends target object with source\r\n * @param target - Object that will extended\r\n * @param source1 - Object that will be used for extending\r\n * @param source2 - Object that will be used for extending\r\n * @param source3 - Object that will be used for extending\r\n * @param source4 - Object that will be used for extending\r\n */\r\nexport function extend<T, U, V, W, X>(target: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X;\r\n/**\r\n * Extends one object with additional properties from other objects, supports deep extend\r\n * @param deepOrObject - Object to be extended or indication that deep copy should be performed\r\n * @param objectN - Objects that will be used for extending, if deep is used first here is target object\r\n * @returns Object Extended object with properties from other objects\r\n */\r\nexport function extend<TResult>(deepOrObject: boolean | Dictionary<any>, ...objectN: Dictionary<any>[]): TResult;\r\n/**\r\n * Extends one object with additional properties from other objects, supports deep extend\r\n * @param deepOrObject - Object to be extended or indication that deep copy should be performed\r\n * @param objectN - Objects that will be used for extending, if deep is used first here is target object\r\n * @returns Object Extended object with properties from other objects\r\n */\r\nexport function extend(deepOrObject: boolean | Dictionary<any>, ...objectN: Dictionary<any>[]): Dictionary\r\n{\r\n return extendLib.apply(null, [deepOrObject, ...objectN]);\r\n}\r\n\r\n/**\r\n * Generates random string consisting from lowercase letters\r\n * @param length - Length of generated string\r\n * @returns number Generated string\r\n */\r\nexport function generateId(length: number): string\r\n{\r\n let result = '';\r\n\r\n for(let x = 0; x < length; x++)\r\n {\r\n result += String.fromCharCode(Math.round(Math.random() * 25 + 97));\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Generates random string of specified length from possible characters\r\n * @param length - Length of generated string\r\n * @param possible - Possible characters used for generation of string\r\n */\r\nexport function generateRandomString(length: number, possible: string = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'): string\r\n{\r\n let text = '';\r\n\r\n for (let i = 0;i < length; i++)\r\n {\r\n text += possible.charAt(Math.floor(Math.random() * possible.length));\r\n }\r\n\r\n return text;\r\n}\r\n\r\n/**\r\n * Converts string in that way that first letter will be lowerCase\r\n * @param text - Text to be converted\r\n */\r\nexport function firstToLowerCase(text: string): string\r\n{\r\n return text.charAt(0).toLowerCase() + text.substr(1);\r\n}\r\n\r\n/**\r\n * Gets indication whether is child descendand of parent\r\n * @param parent - Parent to be tested\r\n * @param child - Child to be looked for\r\n */\r\nexport function isDescendant(parent: HTMLElement, child: HTMLElement): boolean\r\n{\r\n let node = child.parentNode;\r\n\r\n while (node != null)\r\n {\r\n if (node == parent)\r\n {\r\n return true;\r\n }\r\n\r\n node = node.parentNode;\r\n }\r\n\r\n return false;\r\n}\r\n\r\n/**\r\n * Computes offset of element against document\r\n * @param element - Html element which offset is counted\r\n * @param doc - Html document to be used for extracting scroll offset\r\n */\r\nexport function offset(element: HTMLElement, doc?: Document)\r\n{\r\n doc = doc || document;\r\n\r\n const rect = element.getBoundingClientRect(),\r\n scrollLeft = window.pageXOffset || doc.documentElement.scrollLeft,\r\n scrollTop = window.pageYOffset || doc.documentElement.scrollTop;\r\n\r\n return {\r\n top: rect.top + scrollTop,\r\n left: rect.left + scrollLeft,\r\n bottom: rect.top + scrollTop + rect.height,\r\n right: rect.left + scrollLeft + rect.width\r\n };\r\n}\r\n\r\n/**\r\n * Converts html string into html DOM\r\n * @param html - Html string to be converted to DOM\r\n * @param doc - Optional html document to be used\r\n */\r\nexport function htmlToElement(html: string, doc?: Document): HTMLElement\r\n{\r\n let htmlDocument = document;\r\n\r\n if(isPresent(doc))\r\n {\r\n htmlDocument = doc;\r\n }\r\n\r\n const template = htmlDocument.createElement('template');\r\n html = html.trim();\r\n template.innerHTML = html;\r\n\r\n return template.content.firstChild as HTMLElement;\r\n}\r\n\r\n/**\r\n * Extract values from enum type\r\n * @param enumType - Enum type that will have extracted values\r\n */\r\nexport function getEnumValues<TEnum extends Enum>(enumType: TEnum): ValueNamePair[]\r\n{\r\n const result: ValueNamePair[] = [];\r\n\r\n Object.keys(enumType).forEach(key =>\r\n {\r\n if(isNaN(+key))\r\n {\r\n return;\r\n }\r\n\r\n result.push(\r\n {\r\n value: key,\r\n name: enumType[+key]\r\n });\r\n });\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Safely returns value from object property using string expression\r\n * @param object - Object which property value will be obtained\r\n * @param expression - Expression for obtaining value\r\n */\r\nexport function getValue<TValue = unknown>(object: Dictionary<any>, expression: string): TValue\r\nexport function getValue(object: Dictionary<any>, expression: string): unknown\r\n{\r\n return expression.split('.').reduce((o, i) =>\r\n {\r\n if(o)\r\n {\r\n return o[i];\r\n }\r\n\r\n return null;\r\n }, object);\r\n}\r\n\r\n/**\r\n * Sets value to objects property using string expression\r\n * @param object - Object which property value will be set\r\n * @param value - Value that will be set\r\n * @param expression - Expression for setting value\r\n */\r\nexport function setValue(object: Dictionary<any>, value: unknown, expression: string): void\r\n{\r\n const parts = expression.split('.');\r\n\r\n parts.forEach((part, index) =>\r\n {\r\n //last item value is assigned\r\n if(index == parts.length - 1)\r\n {\r\n if(isPresent(value))\r\n {\r\n object[part] = value;\r\n }\r\n\r\n return;\r\n }\r\n\r\n object = object[part] = object[part] ?? {};\r\n });\r\n}\r\n\r\n/**\r\n * Formats string using '%s', to print '%s' you have to use '%%s'\r\n * @param str - String containing substitution constants\r\n * @param args - Arguments that are used for replacement\r\n */\r\nexport function format(str: string, ...args: unknown[]): string\r\n{\r\n let i = 0;\r\n\r\n return str.replace(/((?!%).)%s/g, (_sub, substArgs) => `${substArgs[0]}${args[i++]}`).replace(/%%s/g, '%s');\r\n}\r\n\r\n/**\r\n * Performs flatMap over provided array\r\n * @param array - Array to be reduced using flatMap\r\n */\r\nexport function flatMapArray<TItem>(array: TItem[][]): TItem[]\r\n{\r\n return array.reduce((acc, x) => acc.concat(x), []);\r\n}\r\n\r\n/**\r\n * Serialize object to string that is usable as url query parameter\r\n * @param obj - Object to be serialized\r\n * @param replacer - Function that can be used for replacing provided values\r\n */\r\nexport function serializeToUrlQuery<TObj>(obj: TObj, replacer?: (this: any, key: string, value: any) => any): string\r\n{\r\n return btoa(encodeURIComponent(JSON.stringify(obj, replacer)));\r\n}\r\n\r\n/**\r\n * Deserialize value from url query string into object\r\n * @param queryParamValue - Query param string value\r\n * @param reviver - Function that can be used for correctly deserializing value\r\n */\r\nexport function deserializeFromUrlQuery<TObj>(queryParamValue: string, reviver?: (this: any, key: string, value: any) => any): TObj\r\n{\r\n return JSON.parse(decodeURIComponent(atob(queryParamValue)), reviver);\r\n}\r\n\r\n/**\r\n * Converts id to valid html id\r\n * @param id - Id that is going to be converted to valid html id\r\n * @param charMap - Character map used during normalization\r\n */\r\nexport function validHtmlId(id: string, charMap: StringDictionary = {}): string\r\n{\r\n id = id.toLowerCase()\r\n .replace(/[\\s]+/g, '-')\r\n .replace(/\\./g, '')\r\n .replace(/^(\\d)/g, 'x$1');\r\n\r\n id = normalize(id, charMap);\r\n\r\n return id;\r\n}\r\n\r\n/**\r\n * Checks whether is element overflown either horizontal, or vertical\r\n * @param element - Element to be tested for overflow\r\n */\r\nexport function isOverflown(element: HTMLElement): boolean\r\n{\r\n return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;\r\n}\r\n\r\n/**\r\n * Normalizes string, removing accent\r\n * @param value - String to be normalized\r\n */\r\nexport function normalizeAccent(value: string): string\r\n{\r\n return value.normalize('NFD').replace(/[\\u0300-\\u036f]/g, '');\r\n}\r\n\r\n/**\r\n * Converts instance of Class to equivalent Record type\r\n * @param instance - Instance which type to be converted\r\n * @typeparam TType - Type of instance\r\n */\r\nexport function asDictionary<TType>(instance: TType): AsDictionary<TType>\r\n{\r\n return instance as AsDictionary<TType>;\r\n}\r\n\r\n/**\r\n * Maps all iterable property values of object to \"this\" bounded\r\n * @param this - Object which will be filled with new values\r\n * @param value - Object holding values that will be used for filling\r\n * @param all - Indication whether map only existing properties or everything\r\n */\r\nexport function mapValuesToThis(this: Dictionary<any>, value: Dictionary<any>|undefined|null, all: boolean = false): void\r\n{\r\n if(!value)\r\n {\r\n return;\r\n }\r\n\r\n Object.keys(value).forEach(prop =>\r\n {\r\n if(value[prop] !== undefined && (all || (prop in this)))\r\n {\r\n this[prop] = value[prop];\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Briefly shows simple notification with simple text\r\n * @param show - Indication whether show notification\r\n * @param text - Text to be displayed, defaults to HMR finished text\r\n */\r\nexport function simpleNotification(show: boolean, text: string = 'HMR finished, app updated!'): void\r\n{\r\n if (show)\r\n {\r\n let div: HTMLDivElement|null = document.createElement('div');\r\n div.style.position = 'absolute';\r\n div.style.zIndex = '54345';\r\n div.style.background = 'rgb(255, 255, 255) none repeat scroll 0% 0%';\r\n div.style.padding = '8px';\r\n div.style.fontWeight = 'bold';\r\n div.style.borderRadius = 'bold';\r\n div.style.color = 'rgb(21, 57, 255)';\r\n div.style.left = '47%';\r\n div.style.top = '11px';\r\n div.style.boxShadow = '0px 0px 4px rgb(170, 170, 170)';\r\n div.style.transition = 'all 500ms';\r\n div.style.opacity = '0';\r\n\r\n div.innerText = text;\r\n\r\n document.body.append(div);\r\n\r\n setTimeout(() => div!.style.opacity = '1', 50);\r\n\r\n setTimeout(() =>\r\n {\r\n if(div)\r\n {\r\n div.style.opacity = '0';\r\n\r\n setTimeout(() =>\r\n {\r\n div!.remove();\r\n div = null;\r\n }, 500);\r\n }\r\n }, 2000);\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import { Observable } from 'rxjs';
1
+ import { EmptyError, lastValueFrom, Observable } from 'rxjs';
2
2
  /**
3
3
  * Resolves `PromiseObservableOr` value, if value is Observable then can be completed without value and undefined is resolved
4
4
  * @param value - Value to be solved
@@ -6,13 +6,19 @@ import { Observable } from 'rxjs';
6
6
  export function resolvePromiseObservableOr(value) {
7
7
  return new Promise((resolve, reject) => {
8
8
  if (value instanceof Observable) {
9
- value = value
10
- .toPromise();
9
+ value = lastValueFrom(value);
11
10
  }
12
11
  if (value instanceof Promise) {
13
12
  value
14
13
  .then(resolve)
15
- .catch(error => reject(error));
14
+ .catch(error => {
15
+ //handles observable that completes without value
16
+ if (error instanceof EmptyError) {
17
+ resolve(undefined);
18
+ return;
19
+ }
20
+ reject(error);
21
+ });
16
22
  return;
17
23
  }
18
24
  resolve(value);
@@ -1 +1 @@
1
- {"version":3,"file":"async.js","sourceRoot":"","sources":["../../../../rxjs/src/utils/async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAGhC;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAU,KAAmC;IAEnF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAEnC,IAAG,KAAK,YAAY,UAAU,EAC9B;YACI,KAAK,GAAG,KAAK;iBACR,SAAS,EAAE,CAAC;SACpB;QAED,IAAG,KAAK,YAAY,OAAO,EAC3B;YACI,KAAK;iBACA,IAAI,CAAC,OAAO,CAAC;iBACb,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAEnC,OAAO;SACV;QAED,OAAO,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {Observable} from 'rxjs';\nimport {PromiseObservableOr} from '../types/async';\n\n/**\n * Resolves `PromiseObservableOr` value, if value is Observable then can be completed without value and undefined is resolved\n * @param value - Value to be solved\n */\nexport function resolvePromiseObservableOr<TResult>(value: PromiseObservableOr<TResult>): Promise<TResult|undefined>\n{\n return new Promise((resolve, reject) =>\n {\n if(value instanceof Observable)\n {\n value = value\n .toPromise();\n }\n\n if(value instanceof Promise)\n {\n value\n .then(resolve)\n .catch(error => reject(error));\n\n return;\n }\n \n resolve(value);\n });\n}\n"]}
1
+ {"version":3,"file":"async.js","sourceRoot":"","sources":["../../../../rxjs/src/utils/async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,MAAM,CAAC;AAG3D;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAU,KAAmC;IAEnF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAEnC,IAAG,KAAK,YAAY,UAAU,EAC9B;YACI,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;SAChC;QAED,IAAG,KAAK,YAAY,OAAO,EAC3B;YACI,KAAK;iBACA,IAAI,CAAC,OAAO,CAAC;iBACb,KAAK,CAAC,KAAK,CAAC,EAAE;gBAEX,iDAAiD;gBACjD,IAAG,KAAK,YAAY,UAAU,EAC9B;oBACI,OAAO,CAAC,SAAS,CAAC,CAAC;oBAEnB,OAAO;iBACV;gBAED,MAAM,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;YAEP,OAAO;SACV;QAED,OAAO,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {EmptyError, lastValueFrom, Observable} from 'rxjs';\nimport {PromiseObservableOr} from '../types/async';\n\n/**\n * Resolves `PromiseObservableOr` value, if value is Observable then can be completed without value and undefined is resolved\n * @param value - Value to be solved\n */\nexport function resolvePromiseObservableOr<TResult>(value: PromiseObservableOr<TResult>): Promise<TResult|undefined>\n{\n return new Promise((resolve, reject) =>\n {\n if(value instanceof Observable)\n {\n value = lastValueFrom(value);\n }\n\n if(value instanceof Promise)\n {\n value\n .then(resolve)\n .catch(error =>\n {\n //handles observable that completes without value\n if(error instanceof EmptyError)\n {\n resolve(undefined);\n\n return;\n }\n\n reject(error);\n });\n\n return;\n }\n \n resolve(value);\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bindThis.decorator.js","sourceRoot":"","sources":["../../../src/decorators/bindThis.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,WAA0B,EAAE,UAA8B;;IAEhG,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,+CAAd,UAAU,CAAQ,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/functions';\r\nimport {isFunction} from '../utils/lang';\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<any, any>>\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}"]}
1
+ {"version":3,"file":"bindThis.decorator.js","sourceRoot":"","sources":["../../../src/decorators/bindThis.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,WAA0B,EAAE,UAA8B;;IAEhG,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,0DAAI,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/functions';\r\nimport {isFunction} from '../utils/lang';\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<any, any>>\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}"]}
@@ -6,21 +6,28 @@ import { isFunction, isPresent } from '../utils/lang';
6
6
  export function CallOnce(time) {
7
7
  return function (_target, propertyKey, descriptor) {
8
8
  var _a, _b;
9
- let timeout;
9
+ const timeout = Symbol('ɵTimeout');
10
10
  const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
11
11
  if (!isFunction(originalValue)) {
12
12
  throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey.toString()}', it is not a method.`);
13
13
  }
14
14
  descriptor.value = function (...args) {
15
- if (isPresent(timeout)) {
15
+ if (isPresent(this[timeout])) {
16
16
  return;
17
17
  }
18
+ //timeout variable does not exists
19
+ if (!(timeout in this)) {
20
+ Reflect.defineProperty(this, timeout, {
21
+ writable: true,
22
+ value: null,
23
+ });
24
+ }
18
25
  originalValue.apply(this, args);
19
- timeout = setTimeout(() => {
20
- if (isPresent(timeout)) {
21
- clearTimeout(timeout);
26
+ this[timeout] = setTimeout(() => {
27
+ if (isPresent(this[timeout])) {
28
+ clearTimeout(this[timeout]);
22
29
  }
23
- timeout = null;
30
+ this[timeout] = null;
24
31
  }, time);
25
32
  };
26
33
  return descriptor;
@@ -1 +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,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IAEjC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;;QAEvF,IAAI,OAAoB,CAAC;QACzB,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,+CAAd,UAAU,CAAQ,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/functions';\r\nimport {isFunction, isPresent} from '../utils/lang';\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}"]}
1
+ {"version":3,"file":"callOnce.decorator.js","sourceRoot":"","sources":["../../../src/decorators/callOnce.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IAEjC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;;QAEvF,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACnC,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,0DAAI,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,UAA6C,GAAG,IAAe;YAE9E,IAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAC3B;gBACI,OAAO;aACV;YAED,kCAAkC;YAClC,IAAG,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,EACrB;gBACI,OAAO,CAAC,cAAc,CAAC,IAAI,EACJ,OAAO,EACP;oBACI,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,IAAI;iBACd,CAAC,CAAC;aAC7B;YAED,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEhC,IAAI,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE;gBAE5B,IAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAC3B;oBACI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;iBAC/B;gBAED,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;YACzB,CAAC,EAAE,IAAI,CAAQ,CAAC;QACpB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {Func} from '../types/functions';\r\nimport {isFunction, isPresent} from '../utils/lang';\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 const timeout = Symbol('ɵTimeout');\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(this: {[key: symbol]: number|null}, ...args: unknown[]): void\r\n {\r\n if(isPresent(this[timeout]))\r\n {\r\n return;\r\n }\r\n \r\n //timeout variable does not exists\r\n if(!(timeout in this))\r\n {\r\n Reflect.defineProperty(this,\r\n timeout,\r\n {\r\n writable: true,\r\n value: null,\r\n });\r\n }\r\n\r\n originalValue.apply(this, args);\r\n\r\n this[timeout] = setTimeout(() =>\r\n {\r\n if(isPresent(this[timeout]))\r\n {\r\n clearTimeout(this[timeout]);\r\n }\r\n \r\n this[timeout] = null;\r\n }, time) as any;\r\n };\r\n\r\n return descriptor;\r\n };\r\n}"]}
@@ -1,3 +1,4 @@
1
+ import { __awaiter } from "tslib";
1
2
  import { isFunction, isPresent } from '../utils/lang';
2
3
  /**
3
4
  * Adds special functionality to method call, that debounce method call for specified time
@@ -6,18 +7,45 @@ import { isFunction, isPresent } from '../utils/lang';
6
7
  export function DebounceCall(delay) {
7
8
  return function (_target, propertyKey, descriptor) {
8
9
  var _a, _b;
9
- let timeout;
10
+ const timeout = Symbol('ɵTimeout');
11
+ const resolve = Symbol('ɵResolve');
12
+ const result = Symbol('ɵResult');
10
13
  const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
11
14
  if (!isFunction(originalValue)) {
12
15
  throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey.toString()}', it is not a method.`);
13
16
  }
14
17
  descriptor.value = function (...args) {
15
- if (isPresent(timeout)) {
16
- clearTimeout(timeout);
18
+ //result variable does not exists
19
+ if (!(resolve in this) && !(result in this)) {
20
+ let resolveFn;
21
+ const promise = new Promise(resolve => resolveFn = resolve);
22
+ Reflect.defineProperty(this, resolve, {
23
+ writable: true,
24
+ value: resolveFn,
25
+ });
26
+ Reflect.defineProperty(this, result, {
27
+ writable: true,
28
+ value: promise,
29
+ });
17
30
  }
18
- timeout = setTimeout(() => {
19
- originalValue.apply(this, args);
20
- }, delay);
31
+ if (isPresent(this[timeout])) {
32
+ clearTimeout(this[timeout]);
33
+ this[resolve](undefined);
34
+ this[result] = new Promise(resolveFn => this[resolve] = resolveFn);
35
+ }
36
+ //timeout variable does not exists
37
+ if (!(timeout in this)) {
38
+ Reflect.defineProperty(this, timeout, {
39
+ writable: true,
40
+ value: null,
41
+ });
42
+ }
43
+ this[timeout] = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
44
+ this[resolve](yield originalValue.apply(this, args));
45
+ this[result] = new Promise(resolveFn => this[resolve] = resolveFn);
46
+ this[timeout] = null;
47
+ }), delay);
48
+ return this[result];
21
49
  };
22
50
  return descriptor;
23
51
  };