@ckeditor/ckeditor5-utils 39.0.2 → 40.0.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.
- package/package.json +1 -1
- package/src/areconnectedthroughproperties.d.ts +11 -11
- package/src/areconnectedthroughproperties.js +73 -73
- package/src/ckeditorerror.d.ts +123 -123
- package/src/ckeditorerror.js +176 -176
- package/src/collection.d.ts +427 -427
- package/src/collection.js +575 -575
- package/src/comparearrays.d.ts +30 -30
- package/src/comparearrays.js +47 -47
- package/src/config.d.ts +163 -163
- package/src/config.js +162 -162
- package/src/count.d.ts +18 -18
- package/src/count.js +24 -24
- package/src/delay.d.ts +19 -19
- package/src/delay.js +26 -26
- package/src/diff.d.ts +31 -31
- package/src/diff.js +115 -115
- package/src/difftochanges.d.ts +59 -59
- package/src/difftochanges.js +79 -79
- package/src/dom/createelement.d.ts +57 -57
- package/src/dom/createelement.js +40 -40
- package/src/dom/emittermixin.d.ts +142 -142
- package/src/dom/emittermixin.js +239 -239
- package/src/dom/findclosestscrollableancestor.d.ts +11 -11
- package/src/dom/findclosestscrollableancestor.js +31 -31
- package/src/dom/getancestors.d.ts +17 -17
- package/src/dom/getancestors.js +27 -27
- package/src/dom/getborderwidths.d.ts +24 -24
- package/src/dom/getborderwidths.js +24 -24
- package/src/dom/getcommonancestor.d.ts +12 -12
- package/src/dom/getcommonancestor.js +25 -25
- package/src/dom/getdatafromelement.d.ts +14 -14
- package/src/dom/getdatafromelement.js +20 -20
- package/src/dom/getpositionedancestor.d.ts +10 -10
- package/src/dom/getpositionedancestor.js +22 -22
- package/src/dom/global.d.ts +32 -32
- package/src/dom/global.js +35 -35
- package/src/dom/indexof.d.ts +14 -14
- package/src/dom/indexof.js +21 -21
- package/src/dom/insertat.d.ts +15 -15
- package/src/dom/insertat.js +17 -17
- package/src/dom/iscomment.d.ts +11 -11
- package/src/dom/iscomment.js +14 -14
- package/src/dom/isnode.d.ts +11 -11
- package/src/dom/isnode.js +21 -21
- package/src/dom/isrange.d.ts +11 -11
- package/src/dom/isrange.js +13 -13
- package/src/dom/istext.d.ts +11 -11
- package/src/dom/istext.js +13 -13
- package/src/dom/isvalidattributename.d.ts +10 -10
- package/src/dom/isvalidattributename.js +22 -22
- package/src/dom/isvisible.d.ts +18 -18
- package/src/dom/isvisible.js +20 -20
- package/src/dom/iswindow.d.ts +11 -11
- package/src/dom/iswindow.js +22 -22
- package/src/dom/position.d.ts +211 -208
- package/src/dom/position.js +313 -305
- package/src/dom/rect.d.ts +195 -191
- package/src/dom/rect.js +474 -388
- package/src/dom/remove.d.ts +13 -13
- package/src/dom/remove.js +18 -18
- package/src/dom/resizeobserver.d.ts +74 -74
- package/src/dom/resizeobserver.js +126 -126
- package/src/dom/scroll.d.ts +73 -73
- package/src/dom/scroll.js +383 -383
- package/src/dom/setdatainelement.d.ts +14 -14
- package/src/dom/setdatainelement.js +20 -20
- package/src/dom/tounit.d.ts +22 -22
- package/src/dom/tounit.js +16 -16
- package/src/elementreplacer.d.ts +31 -31
- package/src/elementreplacer.js +43 -43
- package/src/emittermixin.d.ts +312 -312
- package/src/emittermixin.js +453 -453
- package/src/env.d.ts +117 -117
- package/src/env.js +122 -122
- package/src/eventinfo.d.ts +58 -58
- package/src/eventinfo.js +26 -26
- package/src/fastdiff.d.ts +112 -112
- package/src/fastdiff.js +248 -248
- package/src/first.d.ts +11 -11
- package/src/first.js +17 -17
- package/src/focustracker.d.ts +75 -75
- package/src/focustracker.js +95 -95
- package/src/index.d.ts +61 -62
- package/src/index.js +60 -61
- package/src/inserttopriorityarray.d.ts +30 -30
- package/src/inserttopriorityarray.js +21 -21
- package/src/isiterable.d.ts +14 -14
- package/src/isiterable.js +16 -16
- package/src/keyboard.d.ts +126 -126
- package/src/keyboard.js +221 -221
- package/src/keystrokehandler.d.ts +87 -87
- package/src/keystrokehandler.js +122 -122
- package/src/language.d.ts +17 -17
- package/src/language.js +19 -19
- package/src/locale.d.ts +120 -120
- package/src/locale.js +76 -76
- package/src/mapsequal.d.ts +15 -15
- package/src/mapsequal.js +27 -27
- package/src/mix.d.ts +85 -85
- package/src/mix.js +50 -50
- package/src/nth.d.ts +16 -16
- package/src/nth.js +24 -24
- package/src/objecttomap.d.ts +23 -23
- package/src/objecttomap.js +27 -27
- package/src/observablemixin.d.ts +560 -560
- package/src/observablemixin.js +580 -580
- package/src/priorities.d.ts +33 -33
- package/src/priorities.js +23 -23
- package/src/splicearray.d.ts +26 -26
- package/src/splicearray.js +40 -40
- package/src/spy.d.ts +21 -21
- package/src/spy.js +22 -22
- package/src/toarray.d.ts +25 -25
- package/src/toarray.js +7 -7
- package/src/tomap.d.ts +19 -19
- package/src/tomap.js +29 -29
- package/src/translation-service.d.ts +168 -168
- package/src/translation-service.js +198 -198
- package/src/uid.d.ts +15 -15
- package/src/uid.js +57 -57
- package/src/unicode.d.ts +54 -54
- package/src/unicode.js +85 -85
- package/src/verifylicense.d.ts +15 -15
- package/src/verifylicense.js +87 -87
- package/src/version.d.ts +10 -10
- package/src/version.js +153 -153
- package/src/dom/getelementsintersectionrect.d.ts +0 -14
- package/src/dom/getelementsintersectionrect.js +0 -43
- package/src/dom/getscrollableancestors.d.ts +0 -14
- package/src/dom/getscrollableancestors.js +0 -28
package/src/priorities.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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/priorities
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* String representing a priority value.
|
|
10
|
-
*/
|
|
11
|
-
export type PriorityString = 'highest' | 'high' | 'normal' | 'low' | 'lowest' | number;
|
|
12
|
-
/**
|
|
13
|
-
* Provides group of constants to use instead of hardcoding numeric priority values.
|
|
14
|
-
*/
|
|
15
|
-
export interface PrioritiesType {
|
|
16
|
-
/**
|
|
17
|
-
* Converts a string with priority name to it's numeric value. If `Number` is given, it just returns it.
|
|
18
|
-
*
|
|
19
|
-
* @param priority Priority to convert.
|
|
20
|
-
* @returns Converted priority.
|
|
21
|
-
*/
|
|
22
|
-
get(priority?: PriorityString): number;
|
|
23
|
-
readonly highest: number;
|
|
24
|
-
readonly high: number;
|
|
25
|
-
readonly normal: number;
|
|
26
|
-
readonly low: number;
|
|
27
|
-
readonly lowest: number;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Provides group of constants to use instead of hardcoding numeric priority values.
|
|
31
|
-
*/
|
|
32
|
-
declare const priorities: PrioritiesType;
|
|
33
|
-
export default priorities;
|
|
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/priorities
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* String representing a priority value.
|
|
10
|
+
*/
|
|
11
|
+
export type PriorityString = 'highest' | 'high' | 'normal' | 'low' | 'lowest' | number;
|
|
12
|
+
/**
|
|
13
|
+
* Provides group of constants to use instead of hardcoding numeric priority values.
|
|
14
|
+
*/
|
|
15
|
+
export interface PrioritiesType {
|
|
16
|
+
/**
|
|
17
|
+
* Converts a string with priority name to it's numeric value. If `Number` is given, it just returns it.
|
|
18
|
+
*
|
|
19
|
+
* @param priority Priority to convert.
|
|
20
|
+
* @returns Converted priority.
|
|
21
|
+
*/
|
|
22
|
+
get(priority?: PriorityString): number;
|
|
23
|
+
readonly highest: number;
|
|
24
|
+
readonly high: number;
|
|
25
|
+
readonly normal: number;
|
|
26
|
+
readonly low: number;
|
|
27
|
+
readonly lowest: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Provides group of constants to use instead of hardcoding numeric priority values.
|
|
31
|
+
*/
|
|
32
|
+
declare const priorities: PrioritiesType;
|
|
33
|
+
export default priorities;
|
package/src/priorities.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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
|
-
* Provides group of constants to use instead of hardcoding numeric priority values.
|
|
7
|
-
*/
|
|
8
|
-
const priorities = {
|
|
9
|
-
get(priority = 'normal') {
|
|
10
|
-
if (typeof priority != 'number') {
|
|
11
|
-
return this[priority] || this.normal;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return priority;
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
highest: 100000,
|
|
18
|
-
high: 1000,
|
|
19
|
-
normal: 0,
|
|
20
|
-
low: -1000,
|
|
21
|
-
lowest: -100000
|
|
22
|
-
};
|
|
23
|
-
export default priorities;
|
|
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
|
+
* Provides group of constants to use instead of hardcoding numeric priority values.
|
|
7
|
+
*/
|
|
8
|
+
const priorities = {
|
|
9
|
+
get(priority = 'normal') {
|
|
10
|
+
if (typeof priority != 'number') {
|
|
11
|
+
return this[priority] || this.normal;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return priority;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
highest: 100000,
|
|
18
|
+
high: 1000,
|
|
19
|
+
normal: 0,
|
|
20
|
+
low: -1000,
|
|
21
|
+
lowest: -100000
|
|
22
|
+
};
|
|
23
|
+
export default priorities;
|
package/src/splicearray.d.ts
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
|
-
* Splices one array into another. To be used instead of `Array.prototype.splice` as the latter may
|
|
7
|
-
* throw "Maximum call stack size exceeded" when passed huge number of items to insert.
|
|
8
|
-
*
|
|
9
|
-
* Note: in contrary to Array.splice, this function does not modify the original `target`.
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* spliceArray( [ 1, 2 ], [ 3, 4 ], 0, 0 ); // [ 3, 4, 1, 2 ]
|
|
13
|
-
* spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 1 ); // [ 1, 3, 4 ]
|
|
14
|
-
* spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 0 ); // [ 1, 3, 4, 2 ]
|
|
15
|
-
* spliceArray( [ 1, 2 ], [ 3, 4 ], 2, 0 ); // [ 1, 2, 3, 4 ]
|
|
16
|
-
* spliceArray( [ 1, 2 ], [], 0, 1 ); // [ 2 ]
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param target Array to be spliced.
|
|
20
|
-
* @param source Array of elements to be inserted to target.
|
|
21
|
-
* @param start Index at which nodes should be inserted/removed.
|
|
22
|
-
* @param count Number of items.
|
|
23
|
-
*
|
|
24
|
-
* @returns New spliced array.
|
|
25
|
-
*/
|
|
26
|
-
export default function spliceArray<T>(target: Array<T>, source: Array<T>, start: number, count: number): Array<T>;
|
|
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
|
+
* Splices one array into another. To be used instead of `Array.prototype.splice` as the latter may
|
|
7
|
+
* throw "Maximum call stack size exceeded" when passed huge number of items to insert.
|
|
8
|
+
*
|
|
9
|
+
* Note: in contrary to Array.splice, this function does not modify the original `target`.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* spliceArray( [ 1, 2 ], [ 3, 4 ], 0, 0 ); // [ 3, 4, 1, 2 ]
|
|
13
|
+
* spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 1 ); // [ 1, 3, 4 ]
|
|
14
|
+
* spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 0 ); // [ 1, 3, 4, 2 ]
|
|
15
|
+
* spliceArray( [ 1, 2 ], [ 3, 4 ], 2, 0 ); // [ 1, 2, 3, 4 ]
|
|
16
|
+
* spliceArray( [ 1, 2 ], [], 0, 1 ); // [ 2 ]
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param target Array to be spliced.
|
|
20
|
+
* @param source Array of elements to be inserted to target.
|
|
21
|
+
* @param start Index at which nodes should be inserted/removed.
|
|
22
|
+
* @param count Number of items.
|
|
23
|
+
*
|
|
24
|
+
* @returns New spliced array.
|
|
25
|
+
*/
|
|
26
|
+
export default function spliceArray<T>(target: Array<T>, source: Array<T>, start: number, count: number): Array<T>;
|
package/src/splicearray.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
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/splicearray
|
|
7
|
-
*/
|
|
8
|
-
const BIG_CHUNK_SIZE = 10000;
|
|
9
|
-
/**
|
|
10
|
-
* Splices one array into another. To be used instead of `Array.prototype.splice` as the latter may
|
|
11
|
-
* throw "Maximum call stack size exceeded" when passed huge number of items to insert.
|
|
12
|
-
*
|
|
13
|
-
* Note: in contrary to Array.splice, this function does not modify the original `target`.
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* spliceArray( [ 1, 2 ], [ 3, 4 ], 0, 0 ); // [ 3, 4, 1, 2 ]
|
|
17
|
-
* spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 1 ); // [ 1, 3, 4 ]
|
|
18
|
-
* spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 0 ); // [ 1, 3, 4, 2 ]
|
|
19
|
-
* spliceArray( [ 1, 2 ], [ 3, 4 ], 2, 0 ); // [ 1, 2, 3, 4 ]
|
|
20
|
-
* spliceArray( [ 1, 2 ], [], 0, 1 ); // [ 2 ]
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param target Array to be spliced.
|
|
24
|
-
* @param source Array of elements to be inserted to target.
|
|
25
|
-
* @param start Index at which nodes should be inserted/removed.
|
|
26
|
-
* @param count Number of items.
|
|
27
|
-
*
|
|
28
|
-
* @returns New spliced array.
|
|
29
|
-
*/
|
|
30
|
-
export default function spliceArray(target, source, start, count) {
|
|
31
|
-
// In case of performance problems, see: https://github.com/ckeditor/ckeditor5/pull/12429/files#r965850568
|
|
32
|
-
if (Math.max(source.length, target.length) > BIG_CHUNK_SIZE) {
|
|
33
|
-
return target.slice(0, start).concat(source).concat(target.slice(start + count, target.length));
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const newTarget = Array.from(target);
|
|
37
|
-
newTarget.splice(start, count, ...source);
|
|
38
|
-
return newTarget;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
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/splicearray
|
|
7
|
+
*/
|
|
8
|
+
const BIG_CHUNK_SIZE = 10000;
|
|
9
|
+
/**
|
|
10
|
+
* Splices one array into another. To be used instead of `Array.prototype.splice` as the latter may
|
|
11
|
+
* throw "Maximum call stack size exceeded" when passed huge number of items to insert.
|
|
12
|
+
*
|
|
13
|
+
* Note: in contrary to Array.splice, this function does not modify the original `target`.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* spliceArray( [ 1, 2 ], [ 3, 4 ], 0, 0 ); // [ 3, 4, 1, 2 ]
|
|
17
|
+
* spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 1 ); // [ 1, 3, 4 ]
|
|
18
|
+
* spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 0 ); // [ 1, 3, 4, 2 ]
|
|
19
|
+
* spliceArray( [ 1, 2 ], [ 3, 4 ], 2, 0 ); // [ 1, 2, 3, 4 ]
|
|
20
|
+
* spliceArray( [ 1, 2 ], [], 0, 1 ); // [ 2 ]
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param target Array to be spliced.
|
|
24
|
+
* @param source Array of elements to be inserted to target.
|
|
25
|
+
* @param start Index at which nodes should be inserted/removed.
|
|
26
|
+
* @param count Number of items.
|
|
27
|
+
*
|
|
28
|
+
* @returns New spliced array.
|
|
29
|
+
*/
|
|
30
|
+
export default function spliceArray(target, source, start, count) {
|
|
31
|
+
// In case of performance problems, see: https://github.com/ckeditor/ckeditor5/pull/12429/files#r965850568
|
|
32
|
+
if (Math.max(source.length, target.length) > BIG_CHUNK_SIZE) {
|
|
33
|
+
return target.slice(0, start).concat(source).concat(target.slice(start + count, target.length));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const newTarget = Array.from(target);
|
|
37
|
+
newTarget.splice(start, count, ...source);
|
|
38
|
+
return newTarget;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/spy.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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/spy
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Creates a spy function (ala Sinon.js) that can be used to inspect call to it.
|
|
10
|
-
*
|
|
11
|
-
* The following are the present features:
|
|
12
|
-
*
|
|
13
|
-
* * spy.called: property set to `true` if the function has been called at least once.
|
|
14
|
-
*
|
|
15
|
-
* @returns The spy function.
|
|
16
|
-
*/
|
|
17
|
-
declare function spy(): {
|
|
18
|
-
(): void;
|
|
19
|
-
called?: boolean;
|
|
20
|
-
};
|
|
21
|
-
export default spy;
|
|
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/spy
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Creates a spy function (ala Sinon.js) that can be used to inspect call to it.
|
|
10
|
+
*
|
|
11
|
+
* The following are the present features:
|
|
12
|
+
*
|
|
13
|
+
* * spy.called: property set to `true` if the function has been called at least once.
|
|
14
|
+
*
|
|
15
|
+
* @returns The spy function.
|
|
16
|
+
*/
|
|
17
|
+
declare function spy(): {
|
|
18
|
+
(): void;
|
|
19
|
+
called?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export default spy;
|
package/src/spy.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
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/spy
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Creates a spy function (ala Sinon.js) that can be used to inspect call to it.
|
|
10
|
-
*
|
|
11
|
-
* The following are the present features:
|
|
12
|
-
*
|
|
13
|
-
* * spy.called: property set to `true` if the function has been called at least once.
|
|
14
|
-
*
|
|
15
|
-
* @returns The spy function.
|
|
16
|
-
*/
|
|
17
|
-
function spy() {
|
|
18
|
-
return function spy() {
|
|
19
|
-
spy.called = true;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export default spy;
|
|
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/spy
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Creates a spy function (ala Sinon.js) that can be used to inspect call to it.
|
|
10
|
+
*
|
|
11
|
+
* The following are the present features:
|
|
12
|
+
*
|
|
13
|
+
* * spy.called: property set to `true` if the function has been called at least once.
|
|
14
|
+
*
|
|
15
|
+
* @returns The spy function.
|
|
16
|
+
*/
|
|
17
|
+
function spy() {
|
|
18
|
+
return function spy() {
|
|
19
|
+
spy.called = true;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export default spy;
|
package/src/toarray.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
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/toarray
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Transforms any value to an array. If the provided value is already an array, it is returned unchanged.
|
|
10
|
-
*
|
|
11
|
-
* @label MUTABLE
|
|
12
|
-
* @param data The value to transform to an array.
|
|
13
|
-
* @returns An array created from data.
|
|
14
|
-
*/
|
|
15
|
-
export default function toArray<T>(data: ArrayOrItem<T>): Array<T>;
|
|
16
|
-
/**
|
|
17
|
-
* Transforms any value to an array. If the provided value is already an array, it is returned unchanged.
|
|
18
|
-
*
|
|
19
|
-
* @label IMMUTABLE
|
|
20
|
-
* @param data The value to transform to an array.
|
|
21
|
-
* @returns An array created from data.
|
|
22
|
-
*/
|
|
23
|
-
export default function toArray<T>(data: ReadonlyArrayOrItem<T>): ReadonlyArray<T>;
|
|
24
|
-
export type ArrayOrItem<T> = T | Array<T>;
|
|
25
|
-
export type ReadonlyArrayOrItem<T> = T | ReadonlyArray<T>;
|
|
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/toarray
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Transforms any value to an array. If the provided value is already an array, it is returned unchanged.
|
|
10
|
+
*
|
|
11
|
+
* @label MUTABLE
|
|
12
|
+
* @param data The value to transform to an array.
|
|
13
|
+
* @returns An array created from data.
|
|
14
|
+
*/
|
|
15
|
+
export default function toArray<T>(data: ArrayOrItem<T>): Array<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Transforms any value to an array. If the provided value is already an array, it is returned unchanged.
|
|
18
|
+
*
|
|
19
|
+
* @label IMMUTABLE
|
|
20
|
+
* @param data The value to transform to an array.
|
|
21
|
+
* @returns An array created from data.
|
|
22
|
+
*/
|
|
23
|
+
export default function toArray<T>(data: ReadonlyArrayOrItem<T>): ReadonlyArray<T>;
|
|
24
|
+
export type ArrayOrItem<T> = T | Array<T>;
|
|
25
|
+
export type ReadonlyArrayOrItem<T> = T | ReadonlyArray<T>;
|
package/src/toarray.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
export default function toArray(data) {
|
|
6
|
-
return Array.isArray(data) ? data : [data];
|
|
7
|
-
}
|
|
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
|
+
export default function toArray(data) {
|
|
6
|
+
return Array.isArray(data) ? data : [data];
|
|
7
|
+
}
|
package/src/tomap.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
|
-
* Transforms object or iterable to map. Iterable needs to be in the format acceptable by the `Map` constructor.
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* map = toMap( { 'foo': 1, 'bar': 2 } );
|
|
10
|
-
* map = toMap( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
|
|
11
|
-
* map = toMap( anotherMap );
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @param data Object or iterable to transform.
|
|
15
|
-
* @returns Map created from data.
|
|
16
|
-
*/
|
|
17
|
-
export default function toMap<T>(data: {
|
|
18
|
-
readonly [key: string]: T;
|
|
19
|
-
} | Iterable<readonly [string, T]> | null | undefined): Map<string, T>;
|
|
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
|
+
* Transforms object or iterable to map. Iterable needs to be in the format acceptable by the `Map` constructor.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* map = toMap( { 'foo': 1, 'bar': 2 } );
|
|
10
|
+
* map = toMap( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
|
|
11
|
+
* map = toMap( anotherMap );
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param data Object or iterable to transform.
|
|
15
|
+
* @returns Map created from data.
|
|
16
|
+
*/
|
|
17
|
+
export default function toMap<T>(data: {
|
|
18
|
+
readonly [key: string]: T;
|
|
19
|
+
} | Iterable<readonly [string, T]> | null | undefined): Map<string, T>;
|
package/src/tomap.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
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/tomap
|
|
7
|
-
*/
|
|
8
|
-
import objectToMap from './objecttomap';
|
|
9
|
-
import isIterable from './isiterable';
|
|
10
|
-
/**
|
|
11
|
-
* Transforms object or iterable to map. Iterable needs to be in the format acceptable by the `Map` constructor.
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* map = toMap( { 'foo': 1, 'bar': 2 } );
|
|
15
|
-
* map = toMap( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
|
|
16
|
-
* map = toMap( anotherMap );
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param data Object or iterable to transform.
|
|
20
|
-
* @returns Map created from data.
|
|
21
|
-
*/
|
|
22
|
-
export default function toMap(data) {
|
|
23
|
-
if (isIterable(data)) {
|
|
24
|
-
return new Map(data);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return objectToMap(data);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
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/tomap
|
|
7
|
+
*/
|
|
8
|
+
import objectToMap from './objecttomap';
|
|
9
|
+
import isIterable from './isiterable';
|
|
10
|
+
/**
|
|
11
|
+
* Transforms object or iterable to map. Iterable needs to be in the format acceptable by the `Map` constructor.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* map = toMap( { 'foo': 1, 'bar': 2 } );
|
|
15
|
+
* map = toMap( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
|
|
16
|
+
* map = toMap( anotherMap );
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param data Object or iterable to transform.
|
|
20
|
+
* @returns Map created from data.
|
|
21
|
+
*/
|
|
22
|
+
export default function toMap(data) {
|
|
23
|
+
if (isIterable(data)) {
|
|
24
|
+
return new Map(data);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return objectToMap(data);
|
|
28
|
+
}
|
|
29
|
+
}
|