@ckeditor/ckeditor5-utils 40.0.0 → 40.2.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 (135) hide show
  1. package/CHANGELOG.md +26 -26
  2. package/LICENSE.md +3 -3
  3. package/package.json +1 -1
  4. package/src/abortabledebounce.d.ts +17 -0
  5. package/src/abortabledebounce.js +22 -0
  6. package/src/areconnectedthroughproperties.d.ts +11 -11
  7. package/src/areconnectedthroughproperties.js +73 -73
  8. package/src/ckeditorerror.d.ts +123 -123
  9. package/src/ckeditorerror.js +176 -176
  10. package/src/collection.d.ts +433 -427
  11. package/src/collection.js +583 -575
  12. package/src/comparearrays.d.ts +30 -30
  13. package/src/comparearrays.js +47 -47
  14. package/src/config.d.ts +163 -163
  15. package/src/config.js +163 -162
  16. package/src/count.d.ts +18 -18
  17. package/src/count.js +24 -24
  18. package/src/delay.d.ts +19 -19
  19. package/src/delay.js +26 -26
  20. package/src/diff.d.ts +31 -31
  21. package/src/diff.js +115 -115
  22. package/src/difftochanges.d.ts +59 -59
  23. package/src/difftochanges.js +79 -79
  24. package/src/dom/createelement.d.ts +57 -57
  25. package/src/dom/createelement.js +40 -40
  26. package/src/dom/emittermixin.d.ts +142 -142
  27. package/src/dom/emittermixin.js +239 -239
  28. package/src/dom/findclosestscrollableancestor.d.ts +11 -11
  29. package/src/dom/findclosestscrollableancestor.js +31 -31
  30. package/src/dom/getancestors.d.ts +17 -17
  31. package/src/dom/getancestors.js +27 -27
  32. package/src/dom/getborderwidths.d.ts +24 -24
  33. package/src/dom/getborderwidths.js +24 -24
  34. package/src/dom/getcommonancestor.d.ts +12 -12
  35. package/src/dom/getcommonancestor.js +25 -25
  36. package/src/dom/getdatafromelement.d.ts +14 -14
  37. package/src/dom/getdatafromelement.js +20 -20
  38. package/src/dom/getpositionedancestor.d.ts +10 -10
  39. package/src/dom/getpositionedancestor.js +22 -22
  40. package/src/dom/global.d.ts +32 -32
  41. package/src/dom/global.js +35 -35
  42. package/src/dom/indexof.d.ts +14 -14
  43. package/src/dom/indexof.js +21 -21
  44. package/src/dom/insertat.d.ts +15 -15
  45. package/src/dom/insertat.js +17 -17
  46. package/src/dom/iscomment.d.ts +11 -11
  47. package/src/dom/iscomment.js +14 -14
  48. package/src/dom/isnode.d.ts +11 -11
  49. package/src/dom/isnode.js +21 -21
  50. package/src/dom/isrange.d.ts +11 -11
  51. package/src/dom/isrange.js +13 -13
  52. package/src/dom/istext.d.ts +11 -11
  53. package/src/dom/istext.js +13 -13
  54. package/src/dom/isvalidattributename.d.ts +10 -10
  55. package/src/dom/isvalidattributename.js +22 -22
  56. package/src/dom/isvisible.d.ts +18 -18
  57. package/src/dom/isvisible.js +20 -20
  58. package/src/dom/iswindow.d.ts +11 -11
  59. package/src/dom/iswindow.js +22 -22
  60. package/src/dom/position.d.ts +211 -211
  61. package/src/dom/position.js +313 -313
  62. package/src/dom/rect.d.ts +195 -195
  63. package/src/dom/rect.js +474 -474
  64. package/src/dom/remove.d.ts +13 -13
  65. package/src/dom/remove.js +18 -18
  66. package/src/dom/resizeobserver.d.ts +74 -74
  67. package/src/dom/resizeobserver.js +126 -126
  68. package/src/dom/scroll.d.ts +73 -73
  69. package/src/dom/scroll.js +383 -383
  70. package/src/dom/setdatainelement.d.ts +14 -14
  71. package/src/dom/setdatainelement.js +20 -20
  72. package/src/dom/tounit.d.ts +22 -22
  73. package/src/dom/tounit.js +16 -16
  74. package/src/elementreplacer.d.ts +31 -31
  75. package/src/elementreplacer.js +43 -43
  76. package/src/emittermixin.d.ts +312 -312
  77. package/src/emittermixin.js +453 -453
  78. package/src/env.d.ts +117 -117
  79. package/src/env.js +122 -122
  80. package/src/eventinfo.d.ts +58 -58
  81. package/src/eventinfo.js +26 -26
  82. package/src/fastdiff.d.ts +112 -112
  83. package/src/fastdiff.js +248 -248
  84. package/src/first.d.ts +11 -11
  85. package/src/first.js +17 -17
  86. package/src/focustracker.d.ts +75 -75
  87. package/src/focustracker.js +95 -95
  88. package/src/index.d.ts +64 -61
  89. package/src/index.js +63 -60
  90. package/src/inserttopriorityarray.d.ts +30 -30
  91. package/src/inserttopriorityarray.js +21 -21
  92. package/src/isiterable.d.ts +14 -14
  93. package/src/isiterable.js +16 -16
  94. package/src/keyboard.d.ts +126 -126
  95. package/src/keyboard.js +221 -221
  96. package/src/keystrokehandler.d.ts +87 -87
  97. package/src/keystrokehandler.js +122 -122
  98. package/src/language.d.ts +17 -17
  99. package/src/language.js +19 -19
  100. package/src/locale.d.ts +120 -120
  101. package/src/locale.js +76 -76
  102. package/src/mapsequal.d.ts +15 -15
  103. package/src/mapsequal.js +27 -27
  104. package/src/mix.d.ts +85 -85
  105. package/src/mix.js +50 -50
  106. package/src/nth.d.ts +16 -16
  107. package/src/nth.js +24 -24
  108. package/src/objecttomap.d.ts +23 -23
  109. package/src/objecttomap.js +27 -27
  110. package/src/observablemixin.d.ts +560 -560
  111. package/src/observablemixin.js +580 -580
  112. package/src/priorities.d.ts +33 -33
  113. package/src/priorities.js +23 -23
  114. package/src/retry.d.ts +33 -0
  115. package/src/retry.js +47 -0
  116. package/src/splicearray.d.ts +26 -26
  117. package/src/splicearray.js +40 -40
  118. package/src/spy.d.ts +21 -21
  119. package/src/spy.js +22 -22
  120. package/src/toarray.d.ts +25 -25
  121. package/src/toarray.js +7 -7
  122. package/src/tomap.d.ts +19 -19
  123. package/src/tomap.js +29 -29
  124. package/src/translation-service.d.ts +168 -168
  125. package/src/translation-service.js +198 -198
  126. package/src/uid.d.ts +15 -15
  127. package/src/uid.js +57 -57
  128. package/src/unicode.d.ts +54 -54
  129. package/src/unicode.js +85 -85
  130. package/src/verifylicense.d.ts +15 -15
  131. package/src/verifylicense.js +87 -87
  132. package/src/version.d.ts +10 -10
  133. package/src/version.js +153 -153
  134. package/src/wait.d.ts +16 -0
  135. package/src/wait.js +29 -0
package/src/config.js CHANGED
@@ -1,162 +1,163 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module utils/config
7
- */
8
- import { isPlainObject, isElement, cloneDeepWith } from 'lodash-es';
9
- /**
10
- * Handles a configuration dictionary.
11
- *
12
- * @typeParam Cfg A type of the configuration dictionary.
13
- */
14
- export default class Config {
15
- /**
16
- * Creates an instance of the {@link ~Config} class.
17
- *
18
- * @param configurations The initial configurations to be set. Usually, provided by the user.
19
- * @param defaultConfigurations The default configurations. Usually, provided by the system.
20
- */
21
- constructor(configurations, defaultConfigurations) {
22
- this._config = {};
23
- // Set default configuration.
24
- if (defaultConfigurations) {
25
- // Clone the configuration to make sure that the properties will not be shared
26
- // between editors and make the watchdog feature work correctly.
27
- this.define(cloneConfig(defaultConfigurations));
28
- }
29
- // Set initial configuration.
30
- if (configurations) {
31
- this._setObjectToTarget(this._config, configurations);
32
- }
33
- }
34
- set(name, value) {
35
- this._setToTarget(this._config, name, value);
36
- }
37
- define(name, value) {
38
- const isDefine = true;
39
- this._setToTarget(this._config, name, value, isDefine);
40
- }
41
- /**
42
- * Gets the value for a configuration entry.
43
- *
44
- * ```ts
45
- * config.get( 'name' );
46
- * ```
47
- *
48
- * Deep configurations can be retrieved by separating each part with a dot.
49
- *
50
- * ```ts
51
- * config.get( 'toolbar.collapsed' );
52
- * ```
53
- *
54
- * @param name The configuration name. Configuration names are case-sensitive.
55
- * @returns The configuration value or `undefined` if the configuration entry was not found.
56
- */
57
- get(name) {
58
- return this._getFromSource(this._config, name);
59
- }
60
- /**
61
- * Iterates over all top level configuration names.
62
- */
63
- *names() {
64
- for (const name of Object.keys(this._config)) {
65
- yield name;
66
- }
67
- }
68
- /**
69
- * Saves passed configuration to the specified target (nested object).
70
- *
71
- * @param target Nested config object.
72
- * @param name The configuration name or an object from which take properties as
73
- * configuration entries. Configuration names are case-sensitive.
74
- * @param value The configuration value. Used if a name is passed.
75
- * @param isDefine Define if passed configuration should overwrite existing one.
76
- */
77
- _setToTarget(target, name, value, isDefine = false) {
78
- // In case of an object, iterate through it and call `_setToTarget` again for each property.
79
- if (isPlainObject(name)) {
80
- this._setObjectToTarget(target, name, isDefine);
81
- return;
82
- }
83
- // The configuration name should be split into parts if it has dots. E.g. `resize.width` -> [`resize`, `width`].
84
- const parts = name.split('.');
85
- // Take the name of the configuration out of the parts. E.g. `resize.width` -> `width`.
86
- name = parts.pop();
87
- // Iterate over parts to check if currently stored configuration has proper structure.
88
- for (const part of parts) {
89
- // If there is no object for specified part then create one.
90
- if (!isPlainObject(target[part])) {
91
- target[part] = {};
92
- }
93
- // Nested object becomes a target.
94
- target = target[part];
95
- }
96
- // In case of value is an object.
97
- if (isPlainObject(value)) {
98
- // We take care of proper config structure.
99
- if (!isPlainObject(target[name])) {
100
- target[name] = {};
101
- }
102
- target = target[name];
103
- // And iterate through this object calling `_setToTarget` again for each property.
104
- this._setObjectToTarget(target, value, isDefine);
105
- return;
106
- }
107
- // Do nothing if we are defining configuration for non empty name.
108
- if (isDefine && typeof target[name] != 'undefined') {
109
- return;
110
- }
111
- target[name] = value;
112
- }
113
- /**
114
- * Get specified configuration from specified source (nested object).
115
- *
116
- * @param source level of nested object.
117
- * @param name The configuration name. Configuration names are case-sensitive.
118
- * @returns The configuration value or `undefined` if the configuration entry was not found.
119
- */
120
- _getFromSource(source, name) {
121
- // The configuration name should be split into parts if it has dots. E.g. `resize.width` -> [`resize`, `width`].
122
- const parts = name.split('.');
123
- // Take the name of the configuration out of the parts. E.g. `resize.width` -> `width`.
124
- name = parts.pop();
125
- // Iterate over parts to check if currently stored configuration has proper structure.
126
- for (const part of parts) {
127
- if (!isPlainObject(source[part])) {
128
- source = null;
129
- break;
130
- }
131
- // Nested object becomes a source.
132
- source = source[part];
133
- }
134
- // Always returns undefined for non existing configuration.
135
- return source ? cloneConfig(source[name]) : undefined;
136
- }
137
- /**
138
- * Iterates through passed object and calls {@link #_setToTarget} method with object key and value for each property.
139
- *
140
- * @param target Nested config object.
141
- * @param configuration Configuration data set
142
- * @param isDefine Defines if passed configuration is default configuration or not.
143
- */
144
- _setObjectToTarget(target, configuration, isDefine) {
145
- Object.keys(configuration).forEach(key => {
146
- this._setToTarget(target, key, configuration[key], isDefine);
147
- });
148
- }
149
- }
150
- /**
151
- * Clones configuration object or value.
152
- */
153
- function cloneConfig(source) {
154
- return cloneDeepWith(source, leaveDOMReferences);
155
- }
156
- /**
157
- * A customized function for cloneDeepWith.
158
- * It will leave references to DOM Elements instead of cloning them.
159
- */
160
- function leaveDOMReferences(value) {
161
- return isElement(value) ? value : undefined;
162
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module utils/config
7
+ */
8
+ import { isPlainObject, isElement, cloneDeepWith } from 'lodash-es';
9
+ /**
10
+ * Handles a configuration dictionary.
11
+ *
12
+ * @typeParam Cfg A type of the configuration dictionary.
13
+ */
14
+ export default class Config {
15
+ /**
16
+ * Creates an instance of the {@link ~Config} class.
17
+ *
18
+ * @param configurations The initial configurations to be set. Usually, provided by the user.
19
+ * @param defaultConfigurations The default configurations. Usually, provided by the system.
20
+ */
21
+ constructor(configurations, defaultConfigurations) {
22
+ this._config = {};
23
+ // Set default configuration.
24
+ if (defaultConfigurations) {
25
+ // Clone the configuration to make sure that the properties will not be shared
26
+ // between editors and make the watchdog feature work correctly.
27
+ this.define(cloneConfig(defaultConfigurations));
28
+ }
29
+ // Set initial configuration.
30
+ if (configurations) {
31
+ this._setObjectToTarget(this._config, configurations);
32
+ }
33
+ }
34
+ set(name, value) {
35
+ this._setToTarget(this._config, name, value);
36
+ }
37
+ define(name, value) {
38
+ const isDefine = true;
39
+ this._setToTarget(this._config, name, value, isDefine);
40
+ }
41
+ /**
42
+ * Gets the value for a configuration entry.
43
+ *
44
+ * ```ts
45
+ * config.get( 'name' );
46
+ * ```
47
+ *
48
+ * Deep configurations can be retrieved by separating each part with a dot.
49
+ *
50
+ * ```ts
51
+ * config.get( 'toolbar.collapsed' );
52
+ * ```
53
+ *
54
+ * @param name The configuration name. Configuration names are case-sensitive.
55
+ * @returns The configuration value or `undefined` if the configuration entry was not found.
56
+ */
57
+ get(name) {
58
+ return this._getFromSource(this._config, name);
59
+ }
60
+ /**
61
+ * Iterates over all top level configuration names.
62
+ */
63
+ *names() {
64
+ for (const name of Object.keys(this._config)) {
65
+ yield name;
66
+ }
67
+ }
68
+ /**
69
+ * Saves passed configuration to the specified target (nested object).
70
+ *
71
+ * @param target Nested config object.
72
+ * @param name The configuration name or an object from which take properties as
73
+ * configuration entries. Configuration names are case-sensitive.
74
+ * @param value The configuration value. Used if a name is passed.
75
+ * @param isDefine Define if passed configuration should overwrite existing one.
76
+ */
77
+ _setToTarget(target, name, value, isDefine = false) {
78
+ // In case of an object, iterate through it and call `_setToTarget` again for each property.
79
+ if (isPlainObject(name)) {
80
+ this._setObjectToTarget(target, name, isDefine);
81
+ return;
82
+ }
83
+ // The configuration name should be split into parts if it has dots. E.g. `resize.width` -> [`resize`, `width`].
84
+ const parts = name.split('.');
85
+ // Take the name of the configuration out of the parts. E.g. `resize.width` -> `width`.
86
+ name = parts.pop();
87
+ // Iterate over parts to check if currently stored configuration has proper structure.
88
+ for (const part of parts) {
89
+ // If there is no object for specified part then create one.
90
+ if (!isPlainObject(target[part])) {
91
+ target[part] = {};
92
+ }
93
+ // Nested object becomes a target.
94
+ target = target[part];
95
+ }
96
+ // In case of value is an object.
97
+ if (isPlainObject(value)) {
98
+ // We take care of proper config structure.
99
+ if (!isPlainObject(target[name])) {
100
+ target[name] = {};
101
+ }
102
+ target = target[name];
103
+ // And iterate through this object calling `_setToTarget` again for each property.
104
+ this._setObjectToTarget(target, value, isDefine);
105
+ return;
106
+ }
107
+ // Do nothing if we are defining configuration for non empty name.
108
+ if (isDefine && typeof target[name] != 'undefined') {
109
+ return;
110
+ }
111
+ target[name] = value;
112
+ }
113
+ /**
114
+ * Get specified configuration from specified source (nested object).
115
+ *
116
+ * @param source level of nested object.
117
+ * @param name The configuration name. Configuration names are case-sensitive.
118
+ * @returns The configuration value or `undefined` if the configuration entry was not found.
119
+ */
120
+ _getFromSource(source, name) {
121
+ // The configuration name should be split into parts if it has dots. E.g. `resize.width` -> [`resize`, `width`].
122
+ const parts = name.split('.');
123
+ // Take the name of the configuration out of the parts. E.g. `resize.width` -> `width`.
124
+ name = parts.pop();
125
+ // Iterate over parts to check if currently stored configuration has proper structure.
126
+ for (const part of parts) {
127
+ if (!isPlainObject(source[part])) {
128
+ source = null;
129
+ break;
130
+ }
131
+ // Nested object becomes a source.
132
+ source = source[part];
133
+ }
134
+ // Always returns undefined for non existing configuration.
135
+ return source ? cloneConfig(source[name]) : undefined;
136
+ }
137
+ /**
138
+ * Iterates through passed object and calls {@link #_setToTarget} method with object key and value for each property.
139
+ *
140
+ * @param target Nested config object.
141
+ * @param configuration Configuration data set
142
+ * @param isDefine Defines if passed configuration is default configuration or not.
143
+ */
144
+ _setObjectToTarget(target, configuration, isDefine) {
145
+ Object.keys(configuration).forEach(key => {
146
+ this._setToTarget(target, key, configuration[key], isDefine);
147
+ });
148
+ }
149
+ }
150
+ /**
151
+ * Clones configuration object or value.
152
+ */
153
+ function cloneConfig(source) {
154
+ return cloneDeepWith(source, leaveItemReferences);
155
+ }
156
+ /**
157
+ * A customized function for cloneDeepWith.
158
+ * In case if it's a DOM Element it will leave references to DOM Elements instead of cloning them.
159
+ * If it's a function it will leave reference to actuall function.
160
+ */
161
+ function leaveItemReferences(value) {
162
+ return isElement(value) || typeof value === 'function' ? value : undefined;
163
+ }
package/src/count.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module utils/count
7
- */
8
- /**
9
- * Returns the number of items return by the iterator.
10
- *
11
- * ```ts
12
- * count( [ 1, 2, 3, 4, 5 ] ); // 5;
13
- * ```
14
- *
15
- * @param iterable Any iterable.
16
- * @returns Number of items returned by that iterable.
17
- */
18
- export default function count(iterable: Iterable<unknown>): number;
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module utils/count
7
+ */
8
+ /**
9
+ * Returns the number of items return by the iterator.
10
+ *
11
+ * ```ts
12
+ * count( [ 1, 2, 3, 4, 5 ] ); // 5;
13
+ * ```
14
+ *
15
+ * @param iterable Any iterable.
16
+ * @returns Number of items returned by that iterable.
17
+ */
18
+ export default function count(iterable: Iterable<unknown>): number;
package/src/count.js CHANGED
@@ -1,24 +1,24 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module utils/count
7
- */
8
- /**
9
- * Returns the number of items return by the iterator.
10
- *
11
- * ```ts
12
- * count( [ 1, 2, 3, 4, 5 ] ); // 5;
13
- * ```
14
- *
15
- * @param iterable Any iterable.
16
- * @returns Number of items returned by that iterable.
17
- */
18
- export default function count(iterable) {
19
- let count = 0;
20
- for (const _ of iterable) { // eslint-disable-line no-unused-vars
21
- count++;
22
- }
23
- return count;
24
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module utils/count
7
+ */
8
+ /**
9
+ * Returns the number of items return by the iterator.
10
+ *
11
+ * ```ts
12
+ * count( [ 1, 2, 3, 4, 5 ] ); // 5;
13
+ * ```
14
+ *
15
+ * @param iterable Any iterable.
16
+ * @returns Number of items returned by that iterable.
17
+ */
18
+ export default function count(iterable) {
19
+ let count = 0;
20
+ for (const _ of iterable) { // eslint-disable-line no-unused-vars
21
+ count++;
22
+ }
23
+ return count;
24
+ }
package/src/delay.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module utils/delay
7
- */
8
- /**
9
- * Returns a function wrapper that will trigger a function after a specified wait time.
10
- * The timeout can be canceled by calling the cancel function on the returned wrapped function.
11
- *
12
- * @param func The function to wrap.
13
- * @param wait The timeout in ms.
14
- */
15
- export default function delay<T extends (...args: Array<any>) => any>(func: T, wait: number): DelayedFunc<T>;
16
- export interface DelayedFunc<T extends (...args: Array<any>) => any> {
17
- (...args: Parameters<T>): void;
18
- cancel(): void;
19
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module utils/delay
7
+ */
8
+ /**
9
+ * Returns a function wrapper that will trigger a function after a specified wait time.
10
+ * The timeout can be canceled by calling the cancel function on the returned wrapped function.
11
+ *
12
+ * @param func The function to wrap.
13
+ * @param wait The timeout in ms.
14
+ */
15
+ export default function delay<T extends (...args: Array<any>) => any>(func: T, wait: number): DelayedFunc<T>;
16
+ export interface DelayedFunc<T extends (...args: Array<any>) => any> {
17
+ (...args: Parameters<T>): void;
18
+ cancel(): void;
19
+ }
package/src/delay.js CHANGED
@@ -1,26 +1,26 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module utils/delay
7
- */
8
- /* globals setTimeout, clearTimeout */
9
- /**
10
- * Returns a function wrapper that will trigger a function after a specified wait time.
11
- * The timeout can be canceled by calling the cancel function on the returned wrapped function.
12
- *
13
- * @param func The function to wrap.
14
- * @param wait The timeout in ms.
15
- */
16
- export default function delay(func, wait) {
17
- let timer;
18
- function delayed(...args) {
19
- delayed.cancel();
20
- timer = setTimeout(() => func(...args), wait);
21
- }
22
- delayed.cancel = () => {
23
- clearTimeout(timer);
24
- };
25
- return delayed;
26
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module utils/delay
7
+ */
8
+ /* globals setTimeout, clearTimeout */
9
+ /**
10
+ * Returns a function wrapper that will trigger a function after a specified wait time.
11
+ * The timeout can be canceled by calling the cancel function on the returned wrapped function.
12
+ *
13
+ * @param func The function to wrap.
14
+ * @param wait The timeout in ms.
15
+ */
16
+ export default function delay(func, wait) {
17
+ let timer;
18
+ function delayed(...args) {
19
+ delayed.cancel();
20
+ timer = setTimeout(() => func(...args), wait);
21
+ }
22
+ delayed.cancel = () => {
23
+ clearTimeout(timer);
24
+ };
25
+ return delayed;
26
+ }
package/src/diff.d.ts CHANGED
@@ -1,31 +1,31 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * Calculates the difference between two arrays or strings producing an array containing a list of changes
7
- * necessary to transform input into output.
8
- *
9
- * ```ts
10
- * diff( 'aba', 'acca' ); // [ 'equal', 'insert', 'insert', 'delete', 'equal' ]
11
- * ```
12
- *
13
- * This function is based on the "O(NP) Sequence Comparison Algorithm" by Sun Wu, Udi Manber, Gene Myers, Webb Miller.
14
- * Unfortunately, while it gives the most precise results, its to complex for longer strings/arrow (above 200 items).
15
- * Therefore, `diff()` automatically switches to {@link module:utils/fastdiff~fastDiff `fastDiff()`} when detecting
16
- * such a scenario. The return formats of both functions are identical.
17
- *
18
- * @param a Input array or string.
19
- * @param b Output array or string.
20
- * @param cmp Optional function used to compare array values, by default === is used.
21
- * @returns Array of changes.
22
- */
23
- declare function diff<T>(a: ArrayLike<T>, b: ArrayLike<T>, cmp?: (a: T, b: T) => boolean): Array<DiffResult>;
24
- declare namespace diff {
25
- var fastDiff: typeof import("./fastdiff").default;
26
- }
27
- export default diff;
28
- /**
29
- * The element of the result of {@link module:utils/diff~diff} function.
30
- */
31
- export type DiffResult = 'equal' | 'insert' | 'delete';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * Calculates the difference between two arrays or strings producing an array containing a list of changes
7
+ * necessary to transform input into output.
8
+ *
9
+ * ```ts
10
+ * diff( 'aba', 'acca' ); // [ 'equal', 'insert', 'insert', 'delete', 'equal' ]
11
+ * ```
12
+ *
13
+ * This function is based on the "O(NP) Sequence Comparison Algorithm" by Sun Wu, Udi Manber, Gene Myers, Webb Miller.
14
+ * Unfortunately, while it gives the most precise results, its to complex for longer strings/arrow (above 200 items).
15
+ * Therefore, `diff()` automatically switches to {@link module:utils/fastdiff~fastDiff `fastDiff()`} when detecting
16
+ * such a scenario. The return formats of both functions are identical.
17
+ *
18
+ * @param a Input array or string.
19
+ * @param b Output array or string.
20
+ * @param cmp Optional function used to compare array values, by default === is used.
21
+ * @returns Array of changes.
22
+ */
23
+ declare function diff<T>(a: ArrayLike<T>, b: ArrayLike<T>, cmp?: (a: T, b: T) => boolean): Array<DiffResult>;
24
+ declare namespace diff {
25
+ var fastDiff: typeof import("./fastdiff").default;
26
+ }
27
+ export default diff;
28
+ /**
29
+ * The element of the result of {@link module:utils/diff~diff} function.
30
+ */
31
+ export type DiffResult = 'equal' | 'insert' | 'delete';