@sisense/sdk-pivot-query-client 2.17.0

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 (189) hide show
  1. package/LICENSE.md +35 -0
  2. package/README.md +2 -0
  3. package/dist/__test-helpers__/testUtils.d.ts +30 -0
  4. package/dist/__test-helpers__/testUtils.js +89 -0
  5. package/dist/builders/index.d.ts +2 -0
  6. package/dist/builders/index.js +2 -0
  7. package/dist/builders/pivot-data-builder.d.ts +34 -0
  8. package/dist/builders/pivot-data-builder.js +182 -0
  9. package/dist/builders/socket-builder.d.ts +18 -0
  10. package/dist/builders/socket-builder.js +72 -0
  11. package/dist/cjs/__test-helpers__/testUtils.d.ts +30 -0
  12. package/dist/cjs/__test-helpers__/testUtils.js +104 -0
  13. package/dist/cjs/builders/index.d.ts +2 -0
  14. package/dist/cjs/builders/index.js +7 -0
  15. package/dist/cjs/builders/pivot-data-builder.d.ts +34 -0
  16. package/dist/cjs/builders/pivot-data-builder.js +186 -0
  17. package/dist/cjs/builders/socket-builder.d.ts +18 -0
  18. package/dist/cjs/builders/socket-builder.js +79 -0
  19. package/dist/cjs/data-handling/DataService.d.ts +672 -0
  20. package/dist/cjs/data-handling/DataService.js +1364 -0
  21. package/dist/cjs/data-handling/DivergenceComparator.d.ts +7 -0
  22. package/dist/cjs/data-handling/DivergenceComparator.js +20 -0
  23. package/dist/cjs/data-handling/constants.d.ts +44 -0
  24. package/dist/cjs/data-handling/constants.js +43 -0
  25. package/dist/cjs/data-handling/index.d.ts +3 -0
  26. package/dist/cjs/data-handling/index.js +23 -0
  27. package/dist/cjs/data-handling/types.d.ts +104 -0
  28. package/dist/cjs/data-handling/types.js +2 -0
  29. package/dist/cjs/data-handling/utils/createPivotTreeNode.d.ts +13 -0
  30. package/dist/cjs/data-handling/utils/createPivotTreeNode.js +21 -0
  31. package/dist/cjs/data-handling/utils/index.d.ts +4 -0
  32. package/dist/cjs/data-handling/utils/index.js +14 -0
  33. package/dist/cjs/data-handling/utils/jaqlProcessor.d.ts +122 -0
  34. package/dist/cjs/data-handling/utils/jaqlProcessor.js +661 -0
  35. package/dist/cjs/data-handling/utils/pivotTransforms.d.ts +74 -0
  36. package/dist/cjs/data-handling/utils/pivotTransforms.js +373 -0
  37. package/dist/cjs/data-handling/utils/plugins/PluginService.d.ts +135 -0
  38. package/dist/cjs/data-handling/utils/plugins/PluginService.js +383 -0
  39. package/dist/cjs/data-handling/utils/plugins/getters.d.ts +23 -0
  40. package/dist/cjs/data-handling/utils/plugins/getters.js +70 -0
  41. package/dist/cjs/data-handling/utils/plugins/types.d.ts +75 -0
  42. package/dist/cjs/data-handling/utils/plugins/types.js +2 -0
  43. package/dist/cjs/data-handling/utils/plugins/validator.d.ts +13 -0
  44. package/dist/cjs/data-handling/utils/plugins/validator.js +169 -0
  45. package/dist/cjs/data-load/AbstractDataLoadService.d.ts +256 -0
  46. package/dist/cjs/data-load/AbstractDataLoadService.js +473 -0
  47. package/dist/cjs/data-load/DataLoadService.d.ts +63 -0
  48. package/dist/cjs/data-load/DataLoadService.js +152 -0
  49. package/dist/cjs/data-load/SisenseDataLoadService.d.ts +44 -0
  50. package/dist/cjs/data-load/SisenseDataLoadService.js +87 -0
  51. package/dist/cjs/data-load/TestDataLoadService.d.ts +27 -0
  52. package/dist/cjs/data-load/TestDataLoadService.js +76 -0
  53. package/dist/cjs/data-load/constants.d.ts +13 -0
  54. package/dist/cjs/data-load/constants.js +28 -0
  55. package/dist/cjs/data-load/index.d.ts +6 -0
  56. package/dist/cjs/data-load/index.js +14 -0
  57. package/dist/cjs/data-load/sockets/SisenseSocket.d.ts +81 -0
  58. package/dist/cjs/data-load/sockets/SisenseSocket.js +162 -0
  59. package/dist/cjs/data-load/sockets/TestSocket.d.ts +61 -0
  60. package/dist/cjs/data-load/sockets/TestSocket.js +90 -0
  61. package/dist/cjs/data-load/sockets/helpers.d.ts +4 -0
  62. package/dist/cjs/data-load/sockets/helpers.js +27 -0
  63. package/dist/cjs/data-load/sockets/index.d.ts +2 -0
  64. package/dist/cjs/data-load/sockets/index.js +8 -0
  65. package/dist/cjs/data-load/types.d.ts +90 -0
  66. package/dist/cjs/data-load/types.js +2 -0
  67. package/dist/cjs/errors/LoadingCanceledError.d.ts +7 -0
  68. package/dist/cjs/errors/LoadingCanceledError.js +24 -0
  69. package/dist/cjs/errors/index.d.ts +1 -0
  70. package/dist/cjs/errors/index.js +6 -0
  71. package/dist/cjs/index.d.ts +17 -0
  72. package/dist/cjs/index.js +32 -0
  73. package/dist/cjs/package.json +12 -0
  74. package/dist/cjs/pivot-query-client.d.ts +13 -0
  75. package/dist/cjs/pivot-query-client.js +26 -0
  76. package/dist/cjs/tree-structure/AbstractTreeService.d.ts +308 -0
  77. package/dist/cjs/tree-structure/AbstractTreeService.js +716 -0
  78. package/dist/cjs/tree-structure/HeaderTreeService.d.ts +180 -0
  79. package/dist/cjs/tree-structure/HeaderTreeService.js +280 -0
  80. package/dist/cjs/tree-structure/TreeCellMap.d.ts +104 -0
  81. package/dist/cjs/tree-structure/TreeCellMap.js +145 -0
  82. package/dist/cjs/tree-structure/TreeService.d.ts +8 -0
  83. package/dist/cjs/tree-structure/TreeService.js +12 -0
  84. package/dist/cjs/tree-structure/constants.d.ts +6 -0
  85. package/dist/cjs/tree-structure/constants.js +10 -0
  86. package/dist/cjs/tree-structure/index.d.ts +5 -0
  87. package/dist/cjs/tree-structure/index.js +10 -0
  88. package/dist/cjs/tree-structure/types.d.ts +93 -0
  89. package/dist/cjs/tree-structure/types.js +2 -0
  90. package/dist/cjs/tree-structure/utils/index.d.ts +1 -0
  91. package/dist/cjs/tree-structure/utils/index.js +9 -0
  92. package/dist/cjs/tree-structure/utils/treeNode.d.ts +147 -0
  93. package/dist/cjs/tree-structure/utils/treeNode.js +534 -0
  94. package/dist/cjs/utils/array.d.ts +13 -0
  95. package/dist/cjs/utils/array.js +25 -0
  96. package/dist/cjs/utils/cloneObject.d.ts +30 -0
  97. package/dist/cjs/utils/cloneObject.js +225 -0
  98. package/dist/cjs/utils/index.d.ts +3 -0
  99. package/dist/cjs/utils/index.js +9 -0
  100. package/dist/cjs/utils/throttle.d.ts +12 -0
  101. package/dist/cjs/utils/throttle.js +39 -0
  102. package/dist/cjs/utils/types.d.ts +12 -0
  103. package/dist/cjs/utils/types.js +2 -0
  104. package/dist/data-handling/DataService.d.ts +672 -0
  105. package/dist/data-handling/DataService.js +1357 -0
  106. package/dist/data-handling/DivergenceComparator.d.ts +7 -0
  107. package/dist/data-handling/DivergenceComparator.js +16 -0
  108. package/dist/data-handling/constants.d.ts +44 -0
  109. package/dist/data-handling/constants.js +40 -0
  110. package/dist/data-handling/index.d.ts +3 -0
  111. package/dist/data-handling/index.js +4 -0
  112. package/dist/data-handling/types.d.ts +104 -0
  113. package/dist/data-handling/types.js +1 -0
  114. package/dist/data-handling/utils/createPivotTreeNode.d.ts +13 -0
  115. package/dist/data-handling/utils/createPivotTreeNode.js +17 -0
  116. package/dist/data-handling/utils/index.d.ts +4 -0
  117. package/dist/data-handling/utils/index.js +4 -0
  118. package/dist/data-handling/utils/jaqlProcessor.d.ts +122 -0
  119. package/dist/data-handling/utils/jaqlProcessor.js +621 -0
  120. package/dist/data-handling/utils/pivotTransforms.d.ts +74 -0
  121. package/dist/data-handling/utils/pivotTransforms.js +335 -0
  122. package/dist/data-handling/utils/plugins/PluginService.d.ts +135 -0
  123. package/dist/data-handling/utils/plugins/PluginService.js +379 -0
  124. package/dist/data-handling/utils/plugins/getters.d.ts +23 -0
  125. package/dist/data-handling/utils/plugins/getters.js +65 -0
  126. package/dist/data-handling/utils/plugins/types.d.ts +75 -0
  127. package/dist/data-handling/utils/plugins/types.js +1 -0
  128. package/dist/data-handling/utils/plugins/validator.d.ts +13 -0
  129. package/dist/data-handling/utils/plugins/validator.js +165 -0
  130. package/dist/data-load/AbstractDataLoadService.d.ts +256 -0
  131. package/dist/data-load/AbstractDataLoadService.js +466 -0
  132. package/dist/data-load/DataLoadService.d.ts +63 -0
  133. package/dist/data-load/DataLoadService.js +148 -0
  134. package/dist/data-load/SisenseDataLoadService.d.ts +44 -0
  135. package/dist/data-load/SisenseDataLoadService.js +83 -0
  136. package/dist/data-load/TestDataLoadService.d.ts +27 -0
  137. package/dist/data-load/TestDataLoadService.js +69 -0
  138. package/dist/data-load/constants.d.ts +13 -0
  139. package/dist/data-load/constants.js +25 -0
  140. package/dist/data-load/index.d.ts +6 -0
  141. package/dist/data-load/index.js +6 -0
  142. package/dist/data-load/sockets/SisenseSocket.d.ts +81 -0
  143. package/dist/data-load/sockets/SisenseSocket.js +155 -0
  144. package/dist/data-load/sockets/TestSocket.d.ts +61 -0
  145. package/dist/data-load/sockets/TestSocket.js +83 -0
  146. package/dist/data-load/sockets/helpers.d.ts +4 -0
  147. package/dist/data-load/sockets/helpers.js +23 -0
  148. package/dist/data-load/sockets/index.d.ts +2 -0
  149. package/dist/data-load/sockets/index.js +3 -0
  150. package/dist/data-load/types.d.ts +90 -0
  151. package/dist/data-load/types.js +1 -0
  152. package/dist/errors/LoadingCanceledError.d.ts +7 -0
  153. package/dist/errors/LoadingCanceledError.js +20 -0
  154. package/dist/errors/index.d.ts +1 -0
  155. package/dist/errors/index.js +2 -0
  156. package/dist/index.d.ts +17 -0
  157. package/dist/index.js +9 -0
  158. package/dist/pivot-query-client.d.ts +13 -0
  159. package/dist/pivot-query-client.js +22 -0
  160. package/dist/tree-structure/AbstractTreeService.d.ts +308 -0
  161. package/dist/tree-structure/AbstractTreeService.js +712 -0
  162. package/dist/tree-structure/HeaderTreeService.d.ts +180 -0
  163. package/dist/tree-structure/HeaderTreeService.js +276 -0
  164. package/dist/tree-structure/TreeCellMap.d.ts +104 -0
  165. package/dist/tree-structure/TreeCellMap.js +141 -0
  166. package/dist/tree-structure/TreeService.d.ts +8 -0
  167. package/dist/tree-structure/TreeService.js +8 -0
  168. package/dist/tree-structure/constants.d.ts +6 -0
  169. package/dist/tree-structure/constants.js +7 -0
  170. package/dist/tree-structure/index.d.ts +5 -0
  171. package/dist/tree-structure/index.js +4 -0
  172. package/dist/tree-structure/types.d.ts +93 -0
  173. package/dist/tree-structure/types.js +1 -0
  174. package/dist/tree-structure/utils/index.d.ts +1 -0
  175. package/dist/tree-structure/utils/index.js +1 -0
  176. package/dist/tree-structure/utils/treeNode.d.ts +147 -0
  177. package/dist/tree-structure/utils/treeNode.js +515 -0
  178. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
  179. package/dist/utils/array.d.ts +13 -0
  180. package/dist/utils/array.js +21 -0
  181. package/dist/utils/cloneObject.d.ts +30 -0
  182. package/dist/utils/cloneObject.js +221 -0
  183. package/dist/utils/index.d.ts +3 -0
  184. package/dist/utils/index.js +3 -0
  185. package/dist/utils/throttle.d.ts +12 -0
  186. package/dist/utils/throttle.js +35 -0
  187. package/dist/utils/types.d.ts +12 -0
  188. package/dist/utils/types.js +1 -0
  189. package/package.json +61 -0
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.cloneObject = void 0;
15
+ const REFERENCE_CLONE_TYPES = [Date, Error, RegExp, Promise];
16
+ function isReferenceClone(obj, types = REFERENCE_CLONE_TYPES) {
17
+ return types.some((type) => obj instanceof type);
18
+ }
19
+ function hasMatchedItems(searchList, queryList = []) {
20
+ let res = false;
21
+ queryList.forEach((query) => {
22
+ if (searchList.includes(query)) {
23
+ res = true;
24
+ }
25
+ });
26
+ return res;
27
+ }
28
+ function getParentKeys(
29
+ // eslint-disable-next-line @typescript-eslint/default-param-last
30
+ parentKeys = [], key, isArray) {
31
+ const res = [];
32
+ if (isArray) {
33
+ parentKeys.forEach((parentKey) => {
34
+ res.push(`${parentKey}.$`);
35
+ });
36
+ }
37
+ if (parentKeys.length) {
38
+ parentKeys.forEach((parentKey) => {
39
+ res.push(`${parentKey}.${key}`);
40
+ });
41
+ }
42
+ else {
43
+ res.push(key);
44
+ }
45
+ return res;
46
+ }
47
+ function isObject(obj) {
48
+ return !(obj === null || typeof obj === 'undefined' || typeof obj !== 'object');
49
+ }
50
+ function isEmpty(value, excludeTypes) {
51
+ if (isObject(value) && value) {
52
+ if (Array.isArray(value)) {
53
+ return !value.length;
54
+ }
55
+ if (isReferenceClone(value, excludeTypes)) {
56
+ return false;
57
+ }
58
+ return !Object.keys(value).length;
59
+ }
60
+ if (value === undefined || value === null) {
61
+ return true;
62
+ }
63
+ return false;
64
+ }
65
+ function removeLastChildKey(key = '') {
66
+ const parts = key.split('.');
67
+ if (parts.length > 1) {
68
+ parts.pop();
69
+ return parts.join('.');
70
+ }
71
+ return parts[0];
72
+ }
73
+ function shouldBeIncluded(includeKeys, excludeKeys, keysWithParent) {
74
+ if (includeKeys.length) {
75
+ return hasMatchedItems(includeKeys, keysWithParent);
76
+ }
77
+ if (excludeKeys.length) {
78
+ return !hasMatchedItems(excludeKeys, keysWithParent);
79
+ }
80
+ return true;
81
+ }
82
+ function updateIncludeExcludeKeys(obj, include = [], exclude = [], parentKeys = [], includeKeys = {}, excludeKeys = {}, references = [], cachedResults = []) {
83
+ if (!isObject(obj)) {
84
+ return {
85
+ commonIncludeKeys: [],
86
+ commonExcludeKeys: [],
87
+ };
88
+ }
89
+ const index = references.indexOf(obj);
90
+ if (index !== -1) {
91
+ return cachedResults[index];
92
+ }
93
+ references.push(obj);
94
+ const keys = Object.keys(obj);
95
+ const isArray = Array.isArray(obj);
96
+ let commonIncludeKeys = [];
97
+ let commonExcludeKeys = [];
98
+ const childCommonIncludeKeys = [];
99
+ const childCommonExcludeKeys = [];
100
+ keys.forEach((key) => {
101
+ const value = obj[key];
102
+ const keysWithParent = getParentKeys(parentKeys, key, isArray);
103
+ const baseKeysWithParent = parentKeys[0] || '&';
104
+ includeKeys[baseKeysWithParent] = includeKeys[baseKeysWithParent] || [];
105
+ excludeKeys[baseKeysWithParent] = excludeKeys[baseKeysWithParent] || [];
106
+ keysWithParent.forEach((keyWithParent) => {
107
+ if ((include || []).includes(keyWithParent)) {
108
+ includeKeys[baseKeysWithParent].push(keyWithParent);
109
+ commonIncludeKeys.push(keyWithParent);
110
+ }
111
+ // push inserrt keys to parent in case property does not exist at all
112
+ (include || []).forEach((includeKey) => {
113
+ const includeKeyParent = removeLastChildKey(includeKey);
114
+ if (`${includeKeyParent}.$` === baseKeysWithParent ||
115
+ includeKeyParent === baseKeysWithParent) {
116
+ if (!includeKeys[baseKeysWithParent].includes(includeKey)) {
117
+ includeKeys[baseKeysWithParent].push(includeKey);
118
+ }
119
+ if (!commonIncludeKeys.includes(includeKey)) {
120
+ commonIncludeKeys.push(includeKey);
121
+ }
122
+ }
123
+ });
124
+ if ((exclude || []).includes(keyWithParent)) {
125
+ excludeKeys[baseKeysWithParent].push(keyWithParent);
126
+ commonExcludeKeys.push(keyWithParent);
127
+ }
128
+ });
129
+ if (isObject(value)) {
130
+ updateIncludeExcludeKeys(value, include, exclude, keysWithParent, includeKeys, excludeKeys, references, cachedResults);
131
+ }
132
+ });
133
+ if (isObject(obj)) {
134
+ let baseArrayKeysWithParent = parentKeys[0] || '&';
135
+ if (Array.isArray(obj)) {
136
+ baseArrayKeysWithParent = `${baseArrayKeysWithParent}.$`;
137
+ }
138
+ includeKeys[baseArrayKeysWithParent] = (includeKeys[baseArrayKeysWithParent] || []).concat(childCommonIncludeKeys);
139
+ commonIncludeKeys = commonIncludeKeys.concat(childCommonIncludeKeys);
140
+ excludeKeys[baseArrayKeysWithParent] = (excludeKeys[baseArrayKeysWithParent] || []).concat(childCommonExcludeKeys);
141
+ commonExcludeKeys = commonIncludeKeys.concat(childCommonExcludeKeys);
142
+ }
143
+ cachedResults.push({
144
+ commonIncludeKeys,
145
+ commonExcludeKeys,
146
+ });
147
+ return {
148
+ commonIncludeKeys,
149
+ commonExcludeKeys,
150
+ };
151
+ }
152
+ function applyIncludeExclude(obj, options, references = new WeakMap()) {
153
+ const { includeKeys, includeKeysObj, excludeKeys, excludeKeysObj, parentKeys = [], excludeEmpty, referenceClone, } = options || {};
154
+ if (!isObject(obj) || isReferenceClone(obj, referenceClone)) {
155
+ return obj;
156
+ }
157
+ if (references.has(obj)) {
158
+ return references.get(obj);
159
+ }
160
+ const keys = Object.keys(obj);
161
+ const isArray = Array.isArray(obj);
162
+ const res = isArray ? [] : {};
163
+ references.set(obj, res);
164
+ const parentKey = parentKeys[0] || '&';
165
+ const curIncludeKeys = (includeKeysObj || {})[parentKey] || [];
166
+ const curExcludeKeys = (excludeKeysObj || {})[parentKey] || [];
167
+ keys.forEach((key) => {
168
+ const value = obj[key];
169
+ let keysWithParent = [];
170
+ let shouldBeAdded = true;
171
+ if (includeKeys || excludeKeys) {
172
+ shouldBeAdded = shouldBeIncluded(includeKeys || [], excludeKeys || [], [key]);
173
+ }
174
+ else if (includeKeysObj || excludeKeysObj) {
175
+ keysWithParent = getParentKeys(parentKeys, key, isArray);
176
+ shouldBeAdded = shouldBeIncluded(curIncludeKeys, curExcludeKeys, keysWithParent);
177
+ }
178
+ if (shouldBeAdded) {
179
+ const clonedValue = applyIncludeExclude(value, Object.assign(Object.assign({}, options), { parentKeys: keysWithParent }), references);
180
+ if (!excludeEmpty || !isEmpty(clonedValue, referenceClone)) {
181
+ if (isArray) {
182
+ res.push(clonedValue);
183
+ }
184
+ else {
185
+ res[key] = clonedValue;
186
+ }
187
+ }
188
+ }
189
+ });
190
+ return res;
191
+ }
192
+ /**
193
+ * Makes deep clone of the object with ability exclude some properties or include only specific ones
194
+ * (includeKeys && excludeKeys) - simple key name comparison
195
+ * (include && exclude) - with parent hierarchy support, example:
196
+ * 'property1.deep_property2.deep_property3'
197
+ * or for array:
198
+ * 'arrayProperty.0' and 'arrayProperty.$.deep_property'
199
+ *
200
+ * @param {any} obj - object to clone
201
+ * @param {object} [options] - additional behaviour options
202
+ * @param {Array<string>} [options.include] - list of include properties keys
203
+ * @param {Array<string>} [options.includeKeys] - list of include properties keys
204
+ * @param {Array<string>} [options.exclude] - list of exclude properties keys
205
+ * @param {Array<string>} [options.excludeKeys] - list of exclude properties keys
206
+ * @param {boolean} [options.excludeEmpty] - defines if empty objects should be copied or not
207
+ * @param {Array<any>} [options.referenceClone] - defines types which clone by reference
208
+ * @returns {any} - cloned object
209
+ */
210
+ function cloneObject(obj, options) {
211
+ const _a = options || {}, { include, exclude } = _a, restOptions = __rest(_a, ["include", "exclude"]);
212
+ let includeKeysObj;
213
+ let excludeKeysObj;
214
+ if (include || exclude) {
215
+ includeKeysObj = {};
216
+ excludeKeysObj = {};
217
+ updateIncludeExcludeKeys(obj, include, exclude, [], includeKeysObj, excludeKeysObj);
218
+ }
219
+ const applyOptions = Object.assign(Object.assign({}, restOptions), { includeKeysObj,
220
+ excludeKeysObj });
221
+ return applyIncludeExclude(obj, applyOptions);
222
+ }
223
+ exports.cloneObject = cloneObject;
224
+ cloneObject.REFERENCE_CLONE_TYPES = REFERENCE_CLONE_TYPES;
225
+ exports.default = cloneObject;
@@ -0,0 +1,3 @@
1
+ export { cloneObject } from './cloneObject.js';
2
+ export { findIndex } from './array.js';
3
+ export { throttle } from './throttle.js';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throttle = exports.findIndex = exports.cloneObject = void 0;
4
+ var cloneObject_js_1 = require("./cloneObject.js");
5
+ Object.defineProperty(exports, "cloneObject", { enumerable: true, get: function () { return cloneObject_js_1.cloneObject; } });
6
+ var array_js_1 = require("./array.js");
7
+ Object.defineProperty(exports, "findIndex", { enumerable: true, get: function () { return array_js_1.findIndex; } });
8
+ var throttle_js_1 = require("./throttle.js");
9
+ Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return throttle_js_1.throttle; } });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Prevent too frequent function calling in time limit
3
+ *
4
+ * @param {Function} func - function to execute
5
+ * @param {number} limit - time interval in which function should be called only once
6
+ * @returns {Function} - throttled function
7
+ */
8
+ export declare const throttle: (func: Function, limit: number) => {
9
+ (...args: Array<any>): void;
10
+ cancel(): void;
11
+ };
12
+ export default throttle;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throttle = void 0;
4
+ /**
5
+ * Prevent too frequent function calling in time limit
6
+ *
7
+ * @param {Function} func - function to execute
8
+ * @param {number} limit - time interval in which function should be called only once
9
+ * @returns {Function} - throttled function
10
+ */
11
+ const throttle = (func, limit) => {
12
+ let inThrottle;
13
+ let activeTimerID;
14
+ let lastCallArgs = null;
15
+ const resultFn = (...args) => {
16
+ if (inThrottle) {
17
+ lastCallArgs = args;
18
+ }
19
+ else {
20
+ func(...args);
21
+ inThrottle = true;
22
+ lastCallArgs = null;
23
+ activeTimerID = setTimeout(() => {
24
+ inThrottle = false;
25
+ if (lastCallArgs) {
26
+ func(...lastCallArgs);
27
+ lastCallArgs = null;
28
+ }
29
+ }, limit);
30
+ }
31
+ };
32
+ resultFn.cancel = () => {
33
+ clearTimeout(activeTimerID);
34
+ inThrottle = false;
35
+ };
36
+ return resultFn;
37
+ };
38
+ exports.throttle = throttle;
39
+ exports.default = exports.throttle;
@@ -0,0 +1,12 @@
1
+ export declare type Defer = {
2
+ promise: Promise<any>;
3
+ resolve: Function;
4
+ reject: Function;
5
+ };
6
+ declare type CSSProperties = Record<string, string | number | null | undefined>;
7
+ export declare type InputStyles<P = CSSProperties> = P & {
8
+ databarColor?: string;
9
+ };
10
+ export declare type Styles<P = CSSProperties> = P;
11
+ export declare type CloneFn = <T>(obj: T, skipChildren?: boolean) => T;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });