custom-electron-titlebar 3.2.6 → 3.2.10

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 (239) hide show
  1. package/.github/FUNDING.yml +1 -0
  2. package/README.md +15 -24
  3. package/_config.yml +1 -0
  4. package/{lib → build}/browser/browser.d.ts +0 -0
  5. package/{lib → build}/browser/browser.js +0 -0
  6. package/{lib → build}/browser/browser.js.map +0 -0
  7. package/{lib → build}/browser/event.d.ts +0 -0
  8. package/{lib → build}/browser/event.js +2 -1
  9. package/{lib → build}/browser/event.js.map +1 -1
  10. package/{lib → build}/browser/iframe.d.ts +0 -0
  11. package/{lib → build}/browser/iframe.js +0 -0
  12. package/{lib → build}/browser/iframe.js.map +0 -0
  13. package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
  14. package/{lib → build}/browser/keyboardEvent.js +0 -0
  15. package/{lib → build}/browser/keyboardEvent.js.map +0 -0
  16. package/{lib → build}/browser/mouseEvent.d.ts +0 -0
  17. package/{lib → build}/browser/mouseEvent.js +0 -0
  18. package/{lib → build}/browser/mouseEvent.js.map +0 -0
  19. package/{lib → build}/common/arrays.d.ts +0 -0
  20. package/{lib → build}/common/arrays.js +0 -0
  21. package/{lib → build}/common/arrays.js.map +0 -0
  22. package/{lib → build}/common/async.d.ts +0 -0
  23. package/{lib → build}/common/async.js +0 -0
  24. package/{lib → build}/common/async.js.map +0 -0
  25. package/{lib → build}/common/charCode.d.ts +0 -0
  26. package/{lib → build}/common/charCode.js +0 -0
  27. package/{lib → build}/common/charCode.js.map +0 -0
  28. package/{lib → build}/common/color.d.ts +0 -0
  29. package/{lib → build}/common/color.js +0 -0
  30. package/{lib → build}/common/color.js.map +0 -0
  31. package/{lib → build}/common/dom.d.ts +0 -0
  32. package/{lib → build}/common/dom.js +16 -14
  33. package/build/common/dom.js.map +1 -0
  34. package/{lib → build}/common/event.d.ts +0 -0
  35. package/{lib → build}/common/event.js +1 -1
  36. package/build/common/event.js.map +1 -0
  37. package/{lib → build}/common/iterator.d.ts +0 -0
  38. package/{lib → build}/common/iterator.js +0 -0
  39. package/{lib → build}/common/iterator.js.map +0 -0
  40. package/{lib → build}/common/keyCodes.d.ts +0 -0
  41. package/{lib → build}/common/keyCodes.js +0 -0
  42. package/{lib → build}/common/keyCodes.js.map +0 -0
  43. package/{lib → build}/common/lifecycle.d.ts +0 -0
  44. package/{lib → build}/common/lifecycle.js +0 -0
  45. package/{lib → build}/common/lifecycle.js.map +0 -0
  46. package/{lib → build}/common/linkedList.d.ts +0 -0
  47. package/{lib → build}/common/linkedList.js +0 -0
  48. package/{lib → build}/common/linkedList.js.map +0 -0
  49. package/{lib → build}/common/platform.d.ts +0 -0
  50. package/{lib → build}/common/platform.js +0 -0
  51. package/{lib → build}/common/platform.js.map +0 -0
  52. package/{lib → build}/index.d.ts +0 -0
  53. package/{lib → build}/index.js +0 -0
  54. package/{lib → build}/index.js.map +0 -0
  55. package/{lib → build}/menu/menu.d.ts +0 -0
  56. package/{lib → build}/menu/menu.js +38 -38
  57. package/build/menu/menu.js.map +1 -0
  58. package/{lib → build}/menu/menuitem.d.ts +10 -2
  59. package/{lib → build}/menu/menuitem.js +70 -34
  60. package/build/menu/menuitem.js.map +1 -0
  61. package/{lib → build}/menubar.d.ts +0 -0
  62. package/{lib → build}/menubar.js +29 -30
  63. package/build/menubar.js.map +1 -0
  64. package/{lib → build}/themebar.d.ts +0 -0
  65. package/{lib → build}/themebar.js +2 -2
  66. package/build/themebar.js.map +1 -0
  67. package/{lib → build}/titlebar.d.ts +0 -0
  68. package/{lib → build}/titlebar.js +61 -58
  69. package/build/titlebar.js.map +1 -0
  70. package/package.json +13 -7
  71. package/lib/common/dom.js.map +0 -1
  72. package/lib/common/enableNativeMenuCommands.d.ts +0 -1
  73. package/lib/common/enableNativeMenuCommands.js +0 -32
  74. package/lib/common/enableNativeMenuCommands.js.map +0 -1
  75. package/lib/common/event.js.map +0 -1
  76. package/lib/main.d.ts +0 -1
  77. package/lib/main.js +0 -14
  78. package/lib/main.js.map +0 -1
  79. package/lib/menu/menu.js.map +0 -1
  80. package/lib/menu/menuitem.js.map +0 -1
  81. package/lib/menubar.js.map +0 -1
  82. package/lib/themebar.js.map +0 -1
  83. package/lib/titlebar.js.map +0 -1
  84. package/lib/vs/base/browser/browser.js +0 -150
  85. package/lib/vs/base/browser/canIUse.js +0 -58
  86. package/lib/vs/base/browser/codicons.js +0 -37
  87. package/lib/vs/base/browser/contextmenu.js +0 -9
  88. package/lib/vs/base/browser/dnd.js +0 -113
  89. package/lib/vs/base/browser/dom.js +0 -1417
  90. package/lib/vs/base/browser/event.js +0 -36
  91. package/lib/vs/base/browser/fastDomNode.js +0 -265
  92. package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
  93. package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
  94. package/lib/vs/base/browser/history.js +0 -9
  95. package/lib/vs/base/browser/iframe.js +0 -126
  96. package/lib/vs/base/browser/keyboardEvent.js +0 -599
  97. package/lib/vs/base/browser/mouseEvent.js +0 -155
  98. package/lib/vs/base/browser/touch.js +0 -315
  99. package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
  100. package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
  101. package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
  102. package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
  103. package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
  104. package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
  105. package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
  106. package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
  107. package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
  108. package/lib/vs/base/browser/ui/list/list.js +0 -54
  109. package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
  110. package/lib/vs/base/browser/ui/list/listView.js +0 -1388
  111. package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
  112. package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
  113. package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
  114. package/lib/vs/base/browser/ui/list/splice.js +0 -23
  115. package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
  116. package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
  117. package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
  118. package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
  119. package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
  120. package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
  121. package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
  122. package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
  123. package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
  124. package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
  125. package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
  126. package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
  127. package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
  128. package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
  129. package/lib/vs/base/browser/ui/widget.js +0 -69
  130. package/lib/vs/base/common/actions.js +0 -224
  131. package/lib/vs/base/common/amd.js +0 -31
  132. package/lib/vs/base/common/arrays.js +0 -641
  133. package/lib/vs/base/common/assert.js +0 -21
  134. package/lib/vs/base/common/async.js +0 -966
  135. package/lib/vs/base/common/buffer.js +0 -250
  136. package/lib/vs/base/common/cache.js +0 -40
  137. package/lib/vs/base/common/cancellation.js +0 -146
  138. package/lib/vs/base/common/charCode.js +0 -9
  139. package/lib/vs/base/common/codicon.js +0 -136
  140. package/lib/vs/base/common/codicons.js +0 -1378
  141. package/lib/vs/base/common/collections.js +0 -133
  142. package/lib/vs/base/common/color.js +0 -716
  143. package/lib/vs/base/common/comparers.js +0 -280
  144. package/lib/vs/base/common/console.js +0 -142
  145. package/lib/vs/base/common/date.js +0 -113
  146. package/lib/vs/base/common/decorators.js +0 -169
  147. package/lib/vs/base/common/errorMessage.js +0 -93
  148. package/lib/vs/base/common/errors.js +0 -213
  149. package/lib/vs/base/common/errorsWithActions.js +0 -28
  150. package/lib/vs/base/common/event.js +0 -873
  151. package/lib/vs/base/common/extpath.js +0 -401
  152. package/lib/vs/base/common/filters.js +0 -948
  153. package/lib/vs/base/common/functional.js +0 -28
  154. package/lib/vs/base/common/fuzzyScorer.js +0 -811
  155. package/lib/vs/base/common/glob.js +0 -696
  156. package/lib/vs/base/common/hash.js +0 -359
  157. package/lib/vs/base/common/history.js +0 -116
  158. package/lib/vs/base/common/htmlContent.js +0 -162
  159. package/lib/vs/base/common/idGenerator.js +0 -25
  160. package/lib/vs/base/common/iterator.js +0 -118
  161. package/lib/vs/base/common/json.js +0 -1624
  162. package/lib/vs/base/common/jsonEdit.js +0 -272
  163. package/lib/vs/base/common/jsonErrorMessages.js +0 -69
  164. package/lib/vs/base/common/jsonFormatter.js +0 -316
  165. package/lib/vs/base/common/jsonSchema.js +0 -9
  166. package/lib/vs/base/common/keyCodes.js +0 -591
  167. package/lib/vs/base/common/keybindingLabels.js +0 -231
  168. package/lib/vs/base/common/keybindingParser.js +0 -142
  169. package/lib/vs/base/common/labels.js +0 -430
  170. package/lib/vs/base/common/lazy.js +0 -71
  171. package/lib/vs/base/common/lifecycle.js +0 -308
  172. package/lib/vs/base/common/linkedList.js +0 -152
  173. package/lib/vs/base/common/linkedText.js +0 -73
  174. package/lib/vs/base/common/map.js +0 -1108
  175. package/lib/vs/base/common/marshalling.js +0 -80
  176. package/lib/vs/base/common/mime.js +0 -321
  177. package/lib/vs/base/common/navigator.js +0 -50
  178. package/lib/vs/base/common/network.js +0 -160
  179. package/lib/vs/base/common/normalization.js +0 -78
  180. package/lib/vs/base/common/numbers.js +0 -55
  181. package/lib/vs/base/common/objects.js +0 -268
  182. package/lib/vs/base/common/paging.js +0 -190
  183. package/lib/vs/base/common/parsers.js +0 -78
  184. package/lib/vs/base/common/path.js +0 -1550
  185. package/lib/vs/base/common/platform.js +0 -245
  186. package/lib/vs/base/common/process.js +0 -52
  187. package/lib/vs/base/common/processes.js +0 -32
  188. package/lib/vs/base/common/range.js +0 -79
  189. package/lib/vs/base/common/resourceTree.js +0 -185
  190. package/lib/vs/base/common/resources.js +0 -421
  191. package/lib/vs/base/common/scanCode.js +0 -1472
  192. package/lib/vs/base/common/scrollable.js +0 -397
  193. package/lib/vs/base/common/search.js +0 -55
  194. package/lib/vs/base/common/sequence.js +0 -64
  195. package/lib/vs/base/common/severity.js +0 -55
  196. package/lib/vs/base/common/skipList.js +0 -234
  197. package/lib/vs/base/common/stopwatch.js +0 -45
  198. package/lib/vs/base/common/stream.js +0 -418
  199. package/lib/vs/base/common/strings.js +0 -1283
  200. package/lib/vs/base/common/styler.js +0 -9
  201. package/lib/vs/base/common/types.js +0 -296
  202. package/lib/vs/base/common/uint.js +0 -46
  203. package/lib/vs/base/common/uri.js +0 -756
  204. package/lib/vs/base/common/uriIpc.js +0 -154
  205. package/lib/vs/base/common/uuid.js +0 -70
  206. package/lib/vs/nls.mock.js +0 -31
  207. package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
  208. package/lib/vs/platform/actions/common/actions.js +0 -456
  209. package/lib/vs/platform/actions/common/menuService.js +0 -194
  210. package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
  211. package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
  212. package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
  213. package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
  214. package/lib/vs/platform/contextview/browser/contextView.js +0 -15
  215. package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
  216. package/lib/vs/platform/environment/common/argv.js +0 -9
  217. package/lib/vs/platform/environment/common/environment.js +0 -15
  218. package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
  219. package/lib/vs/platform/instantiation/common/extensions.js +0 -26
  220. package/lib/vs/platform/instantiation/common/graph.js +0 -93
  221. package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
  222. package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
  223. package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
  224. package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
  225. package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
  226. package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
  227. package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
  228. package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
  229. package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
  230. package/lib/vs/platform/layout/browser/layoutService.js +0 -14
  231. package/lib/vs/platform/menubar/common/menubar.js +0 -34
  232. package/lib/vs/platform/registry/common/platform.js +0 -38
  233. package/lib/vs/platform/theme/browser/checkbox.js +0 -32
  234. package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
  235. package/lib/vs/platform/theme/common/styler.js +0 -290
  236. package/lib/vs/platform/theme/common/theme.js +0 -21
  237. package/lib/vs/platform/theme/common/themeService.js +0 -176
  238. package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
  239. package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
@@ -1,641 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License. See License.txt in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.getRandomElement = exports.asArray = exports.mapArrayOrNot = exports.pushToEnd = exports.pushToStart = exports.shuffle = exports.arrayInsert = exports.remove = exports.insert = exports.index = exports.range = exports.flatten = exports.commonPrefixLength = exports.firstOrDefault = exports.lastIndex = exports.uniqueFilter = exports.distinctES6 = exports.distinct = exports.isNonEmptyArray = exports.isFalsyOrEmpty = exports.move = exports.coalesceInPlace = exports.coalesce = exports.topAsync = exports.top = exports.delta = exports.sortedDiff = exports.groupBy = exports.mergeSort = exports.findFirstInSorted = exports.binarySearch = exports.equals = exports.tail2 = exports.tail = void 0;
11
-
12
- const errors_1 = require("./errors");
13
- /**
14
- * Returns the last element of an array.
15
- * @param array The array.
16
- * @param n Which element from the end (default is zero).
17
- */
18
-
19
-
20
- function tail(array, n = 0) {
21
- return array[array.length - (1 + n)];
22
- }
23
-
24
- exports.tail = tail;
25
-
26
- function tail2(arr) {
27
- if (arr.length === 0) {
28
- throw new Error('Invalid tail call');
29
- }
30
-
31
- return [arr.slice(0, arr.length - 1), arr[arr.length - 1]];
32
- }
33
-
34
- exports.tail2 = tail2;
35
-
36
- function equals(one, other, itemEquals = (a, b) => a === b) {
37
- if (one === other) {
38
- return true;
39
- }
40
-
41
- if (!one || !other) {
42
- return false;
43
- }
44
-
45
- if (one.length !== other.length) {
46
- return false;
47
- }
48
-
49
- for (let i = 0, len = one.length; i < len; i++) {
50
- if (!itemEquals(one[i], other[i])) {
51
- return false;
52
- }
53
- }
54
-
55
- return true;
56
- }
57
-
58
- exports.equals = equals;
59
-
60
- function binarySearch(array, key, comparator) {
61
- let low = 0,
62
- high = array.length - 1;
63
-
64
- while (low <= high) {
65
- const mid = (low + high) / 2 | 0;
66
- const comp = comparator(array[mid], key);
67
-
68
- if (comp < 0) {
69
- low = mid + 1;
70
- } else if (comp > 0) {
71
- high = mid - 1;
72
- } else {
73
- return mid;
74
- }
75
- }
76
-
77
- return -(low + 1);
78
- }
79
-
80
- exports.binarySearch = binarySearch;
81
- /**
82
- * Takes a sorted array and a function p. The array is sorted in such a way that all elements where p(x) is false
83
- * are located before all elements where p(x) is true.
84
- * @returns the least x for which p(x) is true or array.length if no element fullfills the given function.
85
- */
86
-
87
- function findFirstInSorted(array, p) {
88
- let low = 0,
89
- high = array.length;
90
-
91
- if (high === 0) {
92
- return 0; // no children
93
- }
94
-
95
- while (low < high) {
96
- const mid = Math.floor((low + high) / 2);
97
-
98
- if (p(array[mid])) {
99
- high = mid;
100
- } else {
101
- low = mid + 1;
102
- }
103
- }
104
-
105
- return low;
106
- }
107
-
108
- exports.findFirstInSorted = findFirstInSorted;
109
- /**
110
- * Like `Array#sort` but always stable. Usually runs a little slower `than Array#sort`
111
- * so only use this when actually needing stable sort.
112
- */
113
-
114
- function mergeSort(data, compare) {
115
- _sort(data, compare, 0, data.length - 1, []);
116
-
117
- return data;
118
- }
119
-
120
- exports.mergeSort = mergeSort;
121
-
122
- function _merge(a, compare, lo, mid, hi, aux) {
123
- let leftIdx = lo,
124
- rightIdx = mid + 1;
125
-
126
- for (let i = lo; i <= hi; i++) {
127
- aux[i] = a[i];
128
- }
129
-
130
- for (let i = lo; i <= hi; i++) {
131
- if (leftIdx > mid) {
132
- // left side consumed
133
- a[i] = aux[rightIdx++];
134
- } else if (rightIdx > hi) {
135
- // right side consumed
136
- a[i] = aux[leftIdx++];
137
- } else if (compare(aux[rightIdx], aux[leftIdx]) < 0) {
138
- // right element is less -> comes first
139
- a[i] = aux[rightIdx++];
140
- } else {
141
- // left element comes first (less or equal)
142
- a[i] = aux[leftIdx++];
143
- }
144
- }
145
- }
146
-
147
- function _sort(a, compare, lo, hi, aux) {
148
- if (hi <= lo) {
149
- return;
150
- }
151
-
152
- const mid = lo + (hi - lo) / 2 | 0;
153
-
154
- _sort(a, compare, lo, mid, aux);
155
-
156
- _sort(a, compare, mid + 1, hi, aux);
157
-
158
- if (compare(a[mid], a[mid + 1]) <= 0) {
159
- // left and right are sorted and if the last-left element is less
160
- // or equals than the first-right element there is nothing else
161
- // to do
162
- return;
163
- }
164
-
165
- _merge(a, compare, lo, mid, hi, aux);
166
- }
167
-
168
- function groupBy(data, compare) {
169
- const result = [];
170
- let currentGroup = undefined;
171
-
172
- for (const element of mergeSort(data.slice(0), compare)) {
173
- if (!currentGroup || compare(currentGroup[0], element) !== 0) {
174
- currentGroup = [element];
175
- result.push(currentGroup);
176
- } else {
177
- currentGroup.push(element);
178
- }
179
- }
180
-
181
- return result;
182
- }
183
-
184
- exports.groupBy = groupBy;
185
- /**
186
- * Diffs two *sorted* arrays and computes the splices which apply the diff.
187
- */
188
-
189
- function sortedDiff(before, after, compare) {
190
- const result = [];
191
-
192
- function pushSplice(start, deleteCount, toInsert) {
193
- if (deleteCount === 0 && toInsert.length === 0) {
194
- return;
195
- }
196
-
197
- const latest = result[result.length - 1];
198
-
199
- if (latest && latest.start + latest.deleteCount === start) {
200
- latest.deleteCount += deleteCount;
201
- latest.toInsert.push(...toInsert);
202
- } else {
203
- result.push({
204
- start,
205
- deleteCount,
206
- toInsert
207
- });
208
- }
209
- }
210
-
211
- let beforeIdx = 0;
212
- let afterIdx = 0;
213
-
214
- while (true) {
215
- if (beforeIdx === before.length) {
216
- pushSplice(beforeIdx, 0, after.slice(afterIdx));
217
- break;
218
- }
219
-
220
- if (afterIdx === after.length) {
221
- pushSplice(beforeIdx, before.length - beforeIdx, []);
222
- break;
223
- }
224
-
225
- const beforeElement = before[beforeIdx];
226
- const afterElement = after[afterIdx];
227
- const n = compare(beforeElement, afterElement);
228
-
229
- if (n === 0) {
230
- // equal
231
- beforeIdx += 1;
232
- afterIdx += 1;
233
- } else if (n < 0) {
234
- // beforeElement is smaller -> before element removed
235
- pushSplice(beforeIdx, 1, []);
236
- beforeIdx += 1;
237
- } else if (n > 0) {
238
- // beforeElement is greater -> after element added
239
- pushSplice(beforeIdx, 0, [afterElement]);
240
- afterIdx += 1;
241
- }
242
- }
243
-
244
- return result;
245
- }
246
-
247
- exports.sortedDiff = sortedDiff;
248
- /**
249
- * Takes two *sorted* arrays and computes their delta (removed, added elements).
250
- * Finishes in `Math.min(before.length, after.length)` steps.
251
- */
252
-
253
- function delta(before, after, compare) {
254
- const splices = sortedDiff(before, after, compare);
255
- const removed = [];
256
- const added = [];
257
-
258
- for (const splice of splices) {
259
- removed.push(...before.slice(splice.start, splice.start + splice.deleteCount));
260
- added.push(...splice.toInsert);
261
- }
262
-
263
- return {
264
- removed,
265
- added
266
- };
267
- }
268
-
269
- exports.delta = delta;
270
- /**
271
- * Returns the top N elements from the array.
272
- *
273
- * Faster than sorting the entire array when the array is a lot larger than N.
274
- *
275
- * @param array The unsorted array.
276
- * @param compare A sort function for the elements.
277
- * @param n The number of elements to return.
278
- * @return The first n elemnts from array when sorted with compare.
279
- */
280
-
281
- function top(array, compare, n) {
282
- if (n === 0) {
283
- return [];
284
- }
285
-
286
- const result = array.slice(0, n).sort(compare);
287
- topStep(array, compare, result, n, array.length);
288
- return result;
289
- }
290
-
291
- exports.top = top;
292
- /**
293
- * Asynchronous variant of `top()` allowing for splitting up work in batches between which the event loop can run.
294
- *
295
- * Returns the top N elements from the array.
296
- *
297
- * Faster than sorting the entire array when the array is a lot larger than N.
298
- *
299
- * @param array The unsorted array.
300
- * @param compare A sort function for the elements.
301
- * @param n The number of elements to return.
302
- * @param batch The number of elements to examine before yielding to the event loop.
303
- * @return The first n elemnts from array when sorted with compare.
304
- */
305
-
306
- function topAsync(array, compare, n, batch, token) {
307
- if (n === 0) {
308
- return Promise.resolve([]);
309
- }
310
-
311
- return new Promise((resolve, reject) => {
312
- (async () => {
313
- const o = array.length;
314
- const result = array.slice(0, n).sort(compare);
315
-
316
- for (let i = n, m = Math.min(n + batch, o); i < o; i = m, m = Math.min(m + batch, o)) {
317
- if (i > n) {
318
- await new Promise(resolve => setTimeout(resolve)); // nextTick() would starve I/O.
319
- }
320
-
321
- if (token && token.isCancellationRequested) {
322
- throw errors_1.canceled();
323
- }
324
-
325
- topStep(array, compare, result, i, m);
326
- }
327
-
328
- return result;
329
- })().then(resolve, reject);
330
- });
331
- }
332
-
333
- exports.topAsync = topAsync;
334
-
335
- function topStep(array, compare, result, i, m) {
336
- for (const n = result.length; i < m; i++) {
337
- const element = array[i];
338
-
339
- if (compare(element, result[n - 1]) < 0) {
340
- result.pop();
341
- const j = findFirstInSorted(result, e => compare(element, e) < 0);
342
- result.splice(j, 0, element);
343
- }
344
- }
345
- }
346
- /**
347
- * @returns New array with all falsy values removed. The original array IS NOT modified.
348
- */
349
-
350
-
351
- function coalesce(array) {
352
- return array.filter(e => !!e);
353
- }
354
-
355
- exports.coalesce = coalesce;
356
- /**
357
- * Remove all falsey values from `array`. The original array IS modified.
358
- */
359
-
360
- function coalesceInPlace(array) {
361
- let to = 0;
362
-
363
- for (let i = 0; i < array.length; i++) {
364
- if (!!array[i]) {
365
- array[to] = array[i];
366
- to += 1;
367
- }
368
- }
369
-
370
- array.length = to;
371
- }
372
-
373
- exports.coalesceInPlace = coalesceInPlace;
374
- /**
375
- * Moves the element in the array for the provided positions.
376
- */
377
-
378
- function move(array, from, to) {
379
- array.splice(to, 0, array.splice(from, 1)[0]);
380
- }
381
-
382
- exports.move = move;
383
- /**
384
- * @returns false if the provided object is an array and not empty.
385
- */
386
-
387
- function isFalsyOrEmpty(obj) {
388
- return !Array.isArray(obj) || obj.length === 0;
389
- }
390
-
391
- exports.isFalsyOrEmpty = isFalsyOrEmpty;
392
-
393
- function isNonEmptyArray(obj) {
394
- return Array.isArray(obj) && obj.length > 0;
395
- }
396
-
397
- exports.isNonEmptyArray = isNonEmptyArray;
398
- /**
399
- * Removes duplicates from the given array. The optional keyFn allows to specify
400
- * how elements are checked for equalness by returning a unique string for each.
401
- */
402
-
403
- function distinct(array, keyFn) {
404
- if (!keyFn) {
405
- return array.filter((element, position) => {
406
- return array.indexOf(element) === position;
407
- });
408
- }
409
-
410
- const seen = Object.create(null);
411
- return array.filter(elem => {
412
- const key = keyFn(elem);
413
-
414
- if (seen[key]) {
415
- return false;
416
- }
417
-
418
- seen[key] = true;
419
- return true;
420
- });
421
- }
422
-
423
- exports.distinct = distinct;
424
-
425
- function distinctES6(array) {
426
- const seen = new Set();
427
- return array.filter(element => {
428
- if (seen.has(element)) {
429
- return false;
430
- }
431
-
432
- seen.add(element);
433
- return true;
434
- });
435
- }
436
-
437
- exports.distinctES6 = distinctES6;
438
-
439
- function uniqueFilter(keyFn) {
440
- const seen = Object.create(null);
441
- return element => {
442
- const key = keyFn(element);
443
-
444
- if (seen[key]) {
445
- return false;
446
- }
447
-
448
- seen[key] = true;
449
- return true;
450
- };
451
- }
452
-
453
- exports.uniqueFilter = uniqueFilter;
454
-
455
- function lastIndex(array, fn) {
456
- for (let i = array.length - 1; i >= 0; i--) {
457
- const element = array[i];
458
-
459
- if (fn(element)) {
460
- return i;
461
- }
462
- }
463
-
464
- return -1;
465
- }
466
-
467
- exports.lastIndex = lastIndex;
468
-
469
- function firstOrDefault(array, notFoundValue) {
470
- return array.length > 0 ? array[0] : notFoundValue;
471
- }
472
-
473
- exports.firstOrDefault = firstOrDefault;
474
-
475
- function commonPrefixLength(one, other, equals = (a, b) => a === b) {
476
- let result = 0;
477
-
478
- for (let i = 0, len = Math.min(one.length, other.length); i < len && equals(one[i], other[i]); i++) {
479
- result++;
480
- }
481
-
482
- return result;
483
- }
484
-
485
- exports.commonPrefixLength = commonPrefixLength;
486
-
487
- function flatten(arr) {
488
- return [].concat(...arr);
489
- }
490
-
491
- exports.flatten = flatten;
492
-
493
- function range(arg, to) {
494
- let from = typeof to === 'number' ? arg : 0;
495
-
496
- if (typeof to === 'number') {
497
- from = arg;
498
- } else {
499
- from = 0;
500
- to = arg;
501
- }
502
-
503
- const result = [];
504
-
505
- if (from <= to) {
506
- for (let i = from; i < to; i++) {
507
- result.push(i);
508
- }
509
- } else {
510
- for (let i = from; i > to; i--) {
511
- result.push(i);
512
- }
513
- }
514
-
515
- return result;
516
- }
517
-
518
- exports.range = range;
519
-
520
- function index(array, indexer, mapper) {
521
- return array.reduce((r, t) => {
522
- r[indexer(t)] = mapper ? mapper(t) : t;
523
- return r;
524
- }, Object.create(null));
525
- }
526
-
527
- exports.index = index;
528
- /**
529
- * Inserts an element into an array. Returns a function which, when
530
- * called, will remove that element from the array.
531
- */
532
-
533
- function insert(array, element) {
534
- array.push(element);
535
- return () => remove(array, element);
536
- }
537
-
538
- exports.insert = insert;
539
- /**
540
- * Removes an element from an array if it can be found.
541
- */
542
-
543
- function remove(array, element) {
544
- const index = array.indexOf(element);
545
-
546
- if (index > -1) {
547
- array.splice(index, 1);
548
- return element;
549
- }
550
-
551
- return undefined;
552
- }
553
-
554
- exports.remove = remove;
555
- /**
556
- * Insert `insertArr` inside `target` at `insertIndex`.
557
- * Please don't touch unless you understand https://jsperf.com/inserting-an-array-within-an-array
558
- */
559
-
560
- function arrayInsert(target, insertIndex, insertArr) {
561
- const before = target.slice(0, insertIndex);
562
- const after = target.slice(insertIndex);
563
- return before.concat(insertArr, after);
564
- }
565
-
566
- exports.arrayInsert = arrayInsert;
567
- /**
568
- * Uses Fisher-Yates shuffle to shuffle the given array
569
- */
570
-
571
- function shuffle(array, _seed) {
572
- let rand;
573
-
574
- if (typeof _seed === 'number') {
575
- let seed = _seed; // Seeded random number generator in JS. Modified from:
576
- // https://stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript
577
-
578
- rand = () => {
579
- const x = Math.sin(seed++) * 179426549; // throw away most significant digits and reduce any potential bias
580
-
581
- return x - Math.floor(x);
582
- };
583
- } else {
584
- rand = Math.random;
585
- }
586
-
587
- for (let i = array.length - 1; i > 0; i -= 1) {
588
- const j = Math.floor(rand() * (i + 1));
589
- const temp = array[i];
590
- array[i] = array[j];
591
- array[j] = temp;
592
- }
593
- }
594
-
595
- exports.shuffle = shuffle;
596
- /**
597
- * Pushes an element to the start of the array, if found.
598
- */
599
-
600
- function pushToStart(arr, value) {
601
- const index = arr.indexOf(value);
602
-
603
- if (index > -1) {
604
- arr.splice(index, 1);
605
- arr.unshift(value);
606
- }
607
- }
608
-
609
- exports.pushToStart = pushToStart;
610
- /**
611
- * Pushes an element to the end of the array, if found.
612
- */
613
-
614
- function pushToEnd(arr, value) {
615
- const index = arr.indexOf(value);
616
-
617
- if (index > -1) {
618
- arr.splice(index, 1);
619
- arr.push(value);
620
- }
621
- }
622
-
623
- exports.pushToEnd = pushToEnd;
624
-
625
- function mapArrayOrNot(items, fn) {
626
- return Array.isArray(items) ? items.map(fn) : fn(items);
627
- }
628
-
629
- exports.mapArrayOrNot = mapArrayOrNot;
630
-
631
- function asArray(x) {
632
- return Array.isArray(x) ? x : [x];
633
- }
634
-
635
- exports.asArray = asArray;
636
-
637
- function getRandomElement(arr) {
638
- return arr[Math.floor(Math.random() * arr.length)];
639
- }
640
-
641
- exports.getRandomElement = getRandomElement;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License. See License.txt in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.ok = void 0;
11
- /**
12
- * Throws an error with the provided message if the provided value does not evaluate to a true Javascript value.
13
- */
14
-
15
- function ok(value, message) {
16
- if (!value) {
17
- throw new Error(message ? `Assertion failed (${message})` : 'Assertion Failed');
18
- }
19
- }
20
-
21
- exports.ok = ok;