@ckeditor/ckeditor5-utils 35.3.2 → 36.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/LICENSE.md +1 -1
- package/package.json +5 -5
- package/src/areconnectedthroughproperties.js +7 -9
- package/src/ckeditorerror.js +52 -71
- package/src/collection.js +108 -150
- package/src/comparearrays.js +11 -9
- package/src/config.js +30 -84
- package/src/count.js +6 -4
- package/src/diff.js +8 -6
- package/src/difftochanges.js +18 -15
- package/src/dom/createelement.js +12 -10
- package/src/dom/emittermixin.js +44 -85
- package/src/dom/findclosestscrollableancestor.js +30 -0
- package/src/dom/getancestors.js +3 -3
- package/src/dom/getborderwidths.js +3 -3
- package/src/dom/getcommonancestor.js +4 -4
- package/src/dom/getdatafromelement.js +3 -3
- package/src/dom/getpositionedancestor.js +2 -3
- package/src/dom/global.js +13 -15
- package/src/dom/indexof.js +3 -3
- package/src/dom/insertat.js +4 -4
- package/src/dom/iscomment.js +1 -4
- package/src/dom/isnode.js +1 -4
- package/src/dom/isrange.js +1 -4
- package/src/dom/istext.js +1 -4
- package/src/dom/isvisible.js +1 -4
- package/src/dom/iswindow.js +1 -4
- package/src/dom/position.js +111 -134
- package/src/dom/rect.js +43 -53
- package/src/dom/remove.js +2 -2
- package/src/dom/resizeobserver.js +11 -36
- package/src/dom/scroll.js +86 -92
- package/src/dom/setdatainelement.js +3 -3
- package/src/dom/tounit.js +2 -11
- package/src/elementreplacer.js +3 -3
- package/src/emittermixin.js +49 -49
- package/src/env.js +15 -76
- package/src/eventinfo.js +3 -3
- package/src/fastdiff.js +116 -97
- package/src/first.js +1 -4
- package/src/focustracker.js +12 -20
- package/src/index.js +19 -1
- package/src/inserttopriorityarray.js +3 -3
- package/src/isiterable.js +3 -3
- package/src/keyboard.js +21 -22
- package/src/keystrokehandler.js +27 -25
- package/src/language.js +2 -3
- package/src/locale.js +12 -15
- package/src/mapsequal.js +5 -5
- package/src/mix.js +16 -14
- package/src/nth.js +1 -5
- package/src/objecttomap.js +7 -5
- package/src/observablemixin.js +127 -151
- package/src/priorities.js +1 -10
- package/src/splicearray.js +13 -12
- package/src/spy.js +2 -2
- package/src/toarray.js +1 -1
- package/src/tomap.js +8 -6
- package/src/translation-service.js +71 -53
- package/src/uid.js +6 -4
- package/src/unicode.js +10 -16
- package/src/version.js +33 -27
package/src/isiterable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Checks if value implements iterator interface.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @returns
|
|
11
|
+
* @param value The value to check.
|
|
12
|
+
* @returns True if value implements iterator interface.
|
|
13
13
|
*/
|
|
14
14
|
export default function isIterable(value) {
|
|
15
15
|
return !!(value && value[Symbol.iterator]);
|
package/src/keyboard.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
import CKEditorError from './ckeditorerror';
|
|
@@ -35,9 +35,8 @@ const keyCodeNames = Object.fromEntries(Object.entries(keyCodes).map(([name, cod
|
|
|
35
35
|
*
|
|
36
36
|
* Note: Key names are matched with {@link module:utils/keyboard~keyCodes} in a case-insensitive way.
|
|
37
37
|
*
|
|
38
|
-
* @param
|
|
39
|
-
* or
|
|
40
|
-
* @returns {Number} Key or keystroke code.
|
|
38
|
+
* @param key A key name (see {@link module:utils/keyboard~keyCodes}) or a keystroke data object.
|
|
39
|
+
* @returns Key or keystroke code.
|
|
41
40
|
*/
|
|
42
41
|
export function getCode(key) {
|
|
43
42
|
let keyCode;
|
|
@@ -81,8 +80,8 @@ export function getCode(key) {
|
|
|
81
80
|
* For example, a registered keystroke `Ctrl+A` will be translated to `Cmd+A` on macOS. To disable the translation of some keystroke,
|
|
82
81
|
* use the forced modifier: `Ctrl!+A` (note the exclamation mark).
|
|
83
82
|
*
|
|
84
|
-
* @param
|
|
85
|
-
* @returns
|
|
83
|
+
* @param keystroke The keystroke definition.
|
|
84
|
+
* @returns Keystroke code.
|
|
86
85
|
*/
|
|
87
86
|
export function parseKeystroke(keystroke) {
|
|
88
87
|
if (typeof keystroke == 'string') {
|
|
@@ -96,8 +95,8 @@ export function parseKeystroke(keystroke) {
|
|
|
96
95
|
* Translates any keystroke string text like `"Ctrl+A"` to an
|
|
97
96
|
* environment–specific keystroke, i.e. `"⌘A"` on macOS.
|
|
98
97
|
*
|
|
99
|
-
* @param
|
|
100
|
-
* @returns
|
|
98
|
+
* @param keystroke The keystroke text.
|
|
99
|
+
* @returns The keystroke text specific for the environment.
|
|
101
100
|
*/
|
|
102
101
|
export function getEnvKeystrokeText(keystroke) {
|
|
103
102
|
let keystrokeCode = parseKeystroke(keystroke);
|
|
@@ -115,8 +114,7 @@ export function getEnvKeystrokeText(keystroke) {
|
|
|
115
114
|
/**
|
|
116
115
|
* Returns `true` if the provided key code represents one of the arrow keys.
|
|
117
116
|
*
|
|
118
|
-
* @param
|
|
119
|
-
* @returns {Boolean}
|
|
117
|
+
* @param keyCode A key code as in {@link module:utils/keyboard~KeystrokeInfo#keyCode}.
|
|
120
118
|
*/
|
|
121
119
|
export function isArrowKeyCode(keyCode) {
|
|
122
120
|
return keyCode == keyCodes.arrowright ||
|
|
@@ -131,10 +129,10 @@ export function isArrowKeyCode(keyCode) {
|
|
|
131
129
|
* For instance, in right–to–left (RTL) content languages, pressing the left arrow means moving the selection right (forward)
|
|
132
130
|
* in the model structure. Similarly, pressing the right arrow moves the selection left (backward).
|
|
133
131
|
*
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
132
|
+
* @param keyCode A key code as in {@link module:utils/keyboard~KeystrokeInfo#keyCode}.
|
|
133
|
+
* @param contentLanguageDirection The content language direction, corresponding to
|
|
136
134
|
* {@link module:utils/locale~Locale#contentLanguageDirection}.
|
|
137
|
-
* @returns
|
|
135
|
+
* @returns Localized arrow direction or `undefined` for non-arrow key codes.
|
|
138
136
|
*/
|
|
139
137
|
export function getLocalizedArrowKeyCodeDirection(keyCode, contentLanguageDirection) {
|
|
140
138
|
const isLtrContent = contentLanguageDirection === 'ltr';
|
|
@@ -149,12 +147,14 @@ export function getLocalizedArrowKeyCodeDirection(keyCode, contentLanguageDirect
|
|
|
149
147
|
return 'down';
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Converts a key name to the key code with mapping based on the env.
|
|
152
|
+
*
|
|
153
|
+
* See: {@link module:utils/keyboard~getCode}.
|
|
154
|
+
*
|
|
155
|
+
* @param key The key name (see {@link module:utils/keyboard~keyCodes}).
|
|
156
|
+
* @returns Key code.
|
|
157
|
+
*/
|
|
158
158
|
function getEnvKeyCode(key) {
|
|
159
159
|
// Don't remap modifier key for forced modifiers.
|
|
160
160
|
if (key.endsWith('!')) {
|
|
@@ -170,10 +170,9 @@ function getEnvKeyCode(key) {
|
|
|
170
170
|
* For instance, in right–to–left (RTL) languages, pressing the left arrow means moving forward
|
|
171
171
|
* in the model structure. Similarly, pressing the right arrow moves the selection backward.
|
|
172
172
|
*
|
|
173
|
-
* @param
|
|
174
|
-
* @param
|
|
173
|
+
* @param keyCode A key code as in {@link module:utils/keyboard~KeystrokeInfo#keyCode}.
|
|
174
|
+
* @param contentLanguageDirection The content language direction, corresponding to
|
|
175
175
|
* {@link module:utils/locale~Locale#contentLanguageDirection}.
|
|
176
|
-
* @returns {Boolean}
|
|
177
176
|
*/
|
|
178
177
|
export function isForwardArrowKeyCode(keyCode, contentLanguageDirection) {
|
|
179
178
|
const localizedKeyCodeDirection = getLocalizedArrowKeyCodeDirection(keyCode, contentLanguageDirection);
|
package/src/keystrokehandler.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module utils/keystrokehandler
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import DomEmitterMixin from './dom/emittermixin';
|
|
9
9
|
import { getCode, parseKeystroke } from './keyboard';
|
|
10
10
|
/**
|
|
11
11
|
* Keystroke handler allows registering callbacks for given keystrokes.
|
|
@@ -13,27 +13,31 @@ import { getCode, parseKeystroke } from './keyboard';
|
|
|
13
13
|
* The most frequent use of this class is through the {@link module:core/editor/editor~Editor#keystrokes `editor.keystrokes`}
|
|
14
14
|
* property. It allows listening to keystrokes executed in the editing view:
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* editor.keystrokes.set( 'Ctrl+A', ( keyEvtData, cancel ) => {
|
|
18
|
+
* console.log( 'Ctrl+A has been pressed' );
|
|
19
|
+
* cancel();
|
|
20
|
+
* } );
|
|
21
|
+
* ```
|
|
20
22
|
*
|
|
21
23
|
* However, this utility class can be used in various part of the UI. For instance, a certain {@link module:ui/view~View}
|
|
22
24
|
* can use it like this:
|
|
23
25
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* class MyView extends View {
|
|
28
|
+
* constructor() {
|
|
29
|
+
* this.keystrokes = new KeystrokeHandler();
|
|
27
30
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
31
|
+
* this.keystrokes.set( 'tab', handleTabKey );
|
|
32
|
+
* }
|
|
30
33
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
34
|
+
* render() {
|
|
35
|
+
* super.render();
|
|
33
36
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
+
* this.keystrokes.listenTo( this.element );
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
37
41
|
*
|
|
38
42
|
* That keystroke handler will listen to `keydown` events fired in this view's main element.
|
|
39
43
|
*
|
|
@@ -43,12 +47,10 @@ export default class KeystrokeHandler {
|
|
|
43
47
|
* Creates an instance of the keystroke handler.
|
|
44
48
|
*/
|
|
45
49
|
constructor() {
|
|
46
|
-
this._listener = new
|
|
50
|
+
this._listener = new (DomEmitterMixin())();
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
49
53
|
* Starts listening for `keydown` events from a given emitter.
|
|
50
|
-
*
|
|
51
|
-
* @param {module:utils/emittermixin~Emitter|HTMLElement|Window} emitter
|
|
52
54
|
*/
|
|
53
55
|
listenTo(emitter) {
|
|
54
56
|
// The #_listener works here as a kind of dispatcher. It groups the events coming from the same
|
|
@@ -67,13 +69,13 @@ export default class KeystrokeHandler {
|
|
|
67
69
|
/**
|
|
68
70
|
* Registers a handler for the specified keystroke.
|
|
69
71
|
*
|
|
70
|
-
* @param
|
|
72
|
+
* @param keystroke Keystroke defined in a format accepted by
|
|
71
73
|
* the {@link module:utils/keyboard~parseKeystroke} function.
|
|
72
|
-
* @param
|
|
74
|
+
* @param callback A function called with the
|
|
73
75
|
* {@link module:engine/view/observer/keyobserver~KeyEventData key event data} object and
|
|
74
76
|
* a helper function to call both `preventDefault()` and `stopPropagation()` on the underlying event.
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
+
* @param options Additional options.
|
|
78
|
+
* @param options.priority The priority of the keystroke
|
|
77
79
|
* callback. The higher the priority value the sooner the callback will be executed. Keystrokes having the same priority
|
|
78
80
|
* are called in the order they were added.
|
|
79
81
|
*/
|
|
@@ -99,8 +101,8 @@ export default class KeystrokeHandler {
|
|
|
99
101
|
/**
|
|
100
102
|
* Triggers a keystroke handler for a specified key combination, if such a keystroke was {@link #set defined}.
|
|
101
103
|
*
|
|
102
|
-
* @param
|
|
103
|
-
* @returns
|
|
104
|
+
* @param keyEvtData Key event data.
|
|
105
|
+
* @returns Whether the keystroke was handled.
|
|
104
106
|
*/
|
|
105
107
|
press(keyEvtData) {
|
|
106
108
|
return !!this._listener.fire('_keydown:' + getCode(keyEvtData), keyEvtData);
|
package/src/language.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
const RTL_LANGUAGE_CODES = [
|
|
@@ -12,8 +12,7 @@ const RTL_LANGUAGE_CODES = [
|
|
|
12
12
|
/**
|
|
13
13
|
* Helps determine whether a language text direction is LTR or RTL.
|
|
14
14
|
*
|
|
15
|
-
* @param
|
|
16
|
-
* @returns {module:utils/language~LanguageDirection}
|
|
15
|
+
* @param languageCode The ISO 639-1 or ISO 639-2 language code.
|
|
17
16
|
*/
|
|
18
17
|
export function getLanguageDirection(languageCode) {
|
|
19
18
|
return RTL_LANGUAGE_CODES.includes(languageCode) ? 'rtl' : 'ltr';
|
package/src/locale.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -17,16 +17,16 @@ export default class Locale {
|
|
|
17
17
|
* Creates a new instance of the locale class. Learn more about
|
|
18
18
|
* {@glink features/ui-language configuring the language of the editor}.
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
20
|
+
* @param options Locale configuration.
|
|
21
|
+
* @param options.uiLanguage The editor UI language code in the
|
|
22
22
|
* [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. See {@link #uiLanguage}.
|
|
23
|
-
* @param
|
|
23
|
+
* @param options.contentLanguage The editor content language code in the
|
|
24
24
|
* [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. If not specified, the same as `options.language`.
|
|
25
25
|
* See {@link #contentLanguage}.
|
|
26
26
|
*/
|
|
27
|
-
constructor(
|
|
28
|
-
this.uiLanguage =
|
|
29
|
-
this.contentLanguage =
|
|
27
|
+
constructor({ uiLanguage = 'en', contentLanguage } = {}) {
|
|
28
|
+
this.uiLanguage = uiLanguage;
|
|
29
|
+
this.contentLanguage = contentLanguage || this.uiLanguage;
|
|
30
30
|
this.uiLanguageDirection = getLanguageDirection(this.uiLanguage);
|
|
31
31
|
this.contentLanguageDirection = getLanguageDirection(this.contentLanguage);
|
|
32
32
|
this.t = (message, values) => this._t(message, values);
|
|
@@ -38,12 +38,12 @@ export default class Locale {
|
|
|
38
38
|
* properties instead.
|
|
39
39
|
*
|
|
40
40
|
* @deprecated
|
|
41
|
-
* @member {String}
|
|
42
41
|
*/
|
|
43
42
|
get language() {
|
|
44
43
|
/**
|
|
45
44
|
* The {@link module:utils/locale~Locale#language `Locale#language`} property was deprecated and will
|
|
46
|
-
* be removed in the near future. Please use the {@link #uiLanguage
|
|
45
|
+
* be removed in the near future. Please use the {@link module:utils/locale~Locale#uiLanguage `Locale#uiLanguage`} and
|
|
46
|
+
* {@link module:utils/locale~Locale#contentLanguage `Locale#contentLanguage`} properties instead.
|
|
47
47
|
*
|
|
48
48
|
* @error locale-deprecated-language-property
|
|
49
49
|
*/
|
|
@@ -54,11 +54,6 @@ export default class Locale {
|
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* An unbound version of the {@link #t} method.
|
|
57
|
-
*
|
|
58
|
-
* @private
|
|
59
|
-
* @param {String|module:utils/translation-service~Message} message
|
|
60
|
-
* @param {Number|String|Array.<Number|String>} [values]
|
|
61
|
-
* @returns {String}
|
|
62
57
|
*/
|
|
63
58
|
_t(message, values = []) {
|
|
64
59
|
values = toArray(values);
|
|
@@ -71,7 +66,9 @@ export default class Locale {
|
|
|
71
66
|
return interpolateString(translatedString, values);
|
|
72
67
|
}
|
|
73
68
|
}
|
|
74
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Fills the `%0, %1, ...` string placeholders with values.
|
|
71
|
+
*/
|
|
75
72
|
function interpolateString(string, values) {
|
|
76
73
|
return string.replace(/%(\d+)/g, (match, index) => {
|
|
77
74
|
return (index < values.length) ? values[index] : match;
|
package/src/mapsequal.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @module utils/mapsequal
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
* Checks whether given
|
|
9
|
+
* Checks whether given `Map`s are equal, that is has same size and same key-value pairs.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @returns
|
|
11
|
+
* @param mapA The first map to compare.
|
|
12
|
+
* @param mapB The second map to compare.
|
|
13
|
+
* @returns `true` if given maps are equal, `false` otherwise.
|
|
14
14
|
*/
|
|
15
15
|
export default function mapsEqual(mapA, mapB) {
|
|
16
16
|
if (mapA.size != mapB.size) {
|
package/src/mix.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -9,25 +9,27 @@
|
|
|
9
9
|
* Copies enumerable properties and symbols from the objects given as 2nd+ parameters to the
|
|
10
10
|
* prototype of first object (a constructor).
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* ```
|
|
13
|
+
* class Editor {
|
|
14
|
+
* ...
|
|
15
|
+
* }
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* const SomeMixin = {
|
|
18
|
+
* a() {
|
|
19
|
+
* return 'a';
|
|
20
|
+
* }
|
|
21
|
+
* };
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
+
* mix( Editor, SomeMixin, ... );
|
|
23
24
|
*
|
|
24
|
-
*
|
|
25
|
+
* new Editor().a(); // -> 'a'
|
|
26
|
+
* ```
|
|
25
27
|
*
|
|
26
28
|
* Note: Properties which already exist in the base class will not be overriden.
|
|
27
29
|
*
|
|
28
|
-
* @
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
30
|
+
* @deprecated Use mixin pattern, see: https://www.typescriptlang.org/docs/handbook/mixins.html.
|
|
31
|
+
* @param baseClass Class which prototype will be extended.
|
|
32
|
+
* @param mixins Objects from which to get properties.
|
|
31
33
|
*/
|
|
32
34
|
export default function mix(baseClass, ...mixins) {
|
|
33
35
|
mixins.forEach(mixin => {
|
package/src/nth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
* If it's a normal iterator, then it consumes **all items up to the given index**.
|
|
13
13
|
* Refer to the [Iterators and Generators](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Iterators_and_Generators)
|
|
14
14
|
* guide to learn differences between these interfaces.
|
|
15
|
-
*
|
|
16
|
-
* @param {Number} index
|
|
17
|
-
* @param {Iterable.<*>} iterable
|
|
18
|
-
* @returns {*}
|
|
19
15
|
*/
|
|
20
16
|
export default function nth(index, iterable) {
|
|
21
17
|
for (const item of iterable) {
|
package/src/objecttomap.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Transforms object to map.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const map = objectToMap( { 'foo': 1, 'bar': 2 } );
|
|
13
|
+
* map.get( 'foo' ); // 1
|
|
14
|
+
* ```
|
|
13
15
|
*
|
|
14
16
|
* **Note**: For mixed data (`Object` or `Iterable`) there's a dedicated {@link module:utils/tomap~toMap} function.
|
|
15
17
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @returns
|
|
18
|
+
* @param obj Object to transform.
|
|
19
|
+
* @returns Map created from object.
|
|
18
20
|
*/
|
|
19
21
|
export default function objectToMap(obj) {
|
|
20
22
|
const map = new Map();
|