@ckeditor/ckeditor5-utils 35.3.2 → 35.4.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 (59) hide show
  1. package/package.json +5 -5
  2. package/src/areconnectedthroughproperties.js +5 -7
  3. package/src/ckeditorerror.js +51 -70
  4. package/src/collection.js +106 -148
  5. package/src/comparearrays.js +10 -8
  6. package/src/config.js +29 -83
  7. package/src/count.js +5 -3
  8. package/src/diff.js +7 -5
  9. package/src/difftochanges.js +17 -14
  10. package/src/dom/createelement.js +11 -9
  11. package/src/dom/emittermixin.js +43 -84
  12. package/src/dom/getancestors.js +2 -2
  13. package/src/dom/getborderwidths.js +2 -2
  14. package/src/dom/getcommonancestor.js +3 -3
  15. package/src/dom/getdatafromelement.js +2 -2
  16. package/src/dom/getpositionedancestor.js +1 -2
  17. package/src/dom/global.js +8 -10
  18. package/src/dom/indexof.js +2 -2
  19. package/src/dom/insertat.js +3 -3
  20. package/src/dom/iscomment.js +0 -3
  21. package/src/dom/isnode.js +0 -3
  22. package/src/dom/isrange.js +0 -3
  23. package/src/dom/istext.js +0 -3
  24. package/src/dom/isvisible.js +0 -3
  25. package/src/dom/iswindow.js +0 -3
  26. package/src/dom/position.js +110 -133
  27. package/src/dom/rect.js +42 -52
  28. package/src/dom/remove.js +1 -1
  29. package/src/dom/resizeobserver.js +10 -35
  30. package/src/dom/scroll.js +85 -91
  31. package/src/dom/setdatainelement.js +2 -2
  32. package/src/dom/tounit.js +1 -10
  33. package/src/elementreplacer.js +2 -2
  34. package/src/emittermixin.js +48 -48
  35. package/src/env.js +14 -75
  36. package/src/eventinfo.js +2 -2
  37. package/src/fastdiff.js +115 -96
  38. package/src/first.js +0 -3
  39. package/src/focustracker.js +10 -18
  40. package/src/index.js +17 -0
  41. package/src/inserttopriorityarray.js +2 -2
  42. package/src/isiterable.js +2 -2
  43. package/src/keyboard.js +20 -21
  44. package/src/keystrokehandler.js +26 -24
  45. package/src/language.js +1 -2
  46. package/src/locale.js +11 -14
  47. package/src/mapsequal.js +3 -3
  48. package/src/mix.js +15 -13
  49. package/src/nth.js +0 -4
  50. package/src/objecttomap.js +6 -4
  51. package/src/observablemixin.js +126 -150
  52. package/src/priorities.js +0 -9
  53. package/src/splicearray.js +12 -11
  54. package/src/spy.js +1 -1
  55. package/src/tomap.js +7 -5
  56. package/src/translation-service.js +70 -52
  57. package/src/uid.js +5 -3
  58. package/src/unicode.js +9 -15
  59. package/src/version.js +32 -26
@@ -2,11 +2,11 @@
2
2
  * @license Copyright (c) 2003-2022, 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
- /* eslint-disable @typescript-eslint/unified-signatures, new-cap */
5
+ /* eslint-disable @typescript-eslint/unified-signatures */
6
6
  /**
7
7
  * @module utils/observablemixin
8
8
  */
9
- import { Emitter } from './emittermixin';
9
+ import EmitterMixin from './emittermixin';
10
10
  import CKEditorError from './ckeditorerror';
11
11
  import { isObject } from 'lodash-es';
12
12
  const observablePropertiesSymbol = Symbol('observableProperties');
@@ -14,20 +14,11 @@ const boundObservablesSymbol = Symbol('boundObservables');
14
14
  const boundPropertiesSymbol = Symbol('boundProperties');
15
15
  const decoratedMethods = Symbol('decoratedMethods');
16
16
  const decoratedOriginal = Symbol('decoratedOriginal');
17
- /**
18
- * A mixin that injects the "observable properties" and data binding functionality described in the
19
- * {@link ~Observable} interface.
20
- *
21
- * Read more about the concept of observables in the:
22
- * * {@glink framework/guides/architecture/core-editor-architecture#event-system-and-observables Event system and observables}
23
- * section of the {@glink framework/guides/architecture/core-editor-architecture Core editor architecture} guide,
24
- * * {@glink framework/guides/deep-dive/observables Observables deep dive} guide.
25
- *
26
- * @mixin ObservableMixin
27
- * @mixes module:utils/emittermixin~EmitterMixin
28
- * @implements module:utils/observablemixin~Observable
29
- */
17
+ const defaultObservableClass = ObservableMixin(EmitterMixin());
30
18
  export default function ObservableMixin(base) {
19
+ if (!base) {
20
+ return defaultObservableClass;
21
+ }
31
22
  class Mixin extends base {
32
23
  set(name, value) {
33
24
  // If the first parameter is an Object, iterate over its properties.
@@ -43,15 +34,17 @@ export default function ObservableMixin(base) {
43
34
  /**
44
35
  * Cannot override an existing property.
45
36
  *
46
- * This error is thrown when trying to {@link ~Observable#set set} a property with
37
+ * This error is thrown when trying to {@link module:utils/observablemixin~Observable#set set} a property with
47
38
  * a name of an already existing property. For example:
48
39
  *
49
- * let observable = new Model();
50
- * observable.property = 1;
51
- * observable.set( 'property', 2 ); // throws
40
+ * ```ts
41
+ * let observable = new Model();
42
+ * observable.property = 1;
43
+ * observable.set( 'property', 2 ); // throws
52
44
  *
53
- * observable.set( 'property', 1 );
54
- * observable.set( 'property', 2 ); // ok, because this is an existing property.
45
+ * observable.set( 'property', 1 );
46
+ * observable.set( 'property', 2 ); // ok, because this is an existing property.
47
+ * ```
55
48
  *
56
49
  * @error observable-set-cannot-override
57
50
  */
@@ -112,24 +105,11 @@ export default function ObservableMixin(base) {
112
105
  }
113
106
  });
114
107
  const bindings = new Map();
115
- // @typedef {Object} Binding
116
- // @property {Array} property Property which is bound.
117
- // @property {Array} to Array of observable–property components of the binding (`{ observable: ..., property: .. }`).
118
- // @property {Array} callback A function which processes `to` components.
119
108
  bindProperties.forEach(a => {
120
109
  const binding = { property: a, to: [] };
121
110
  boundProperties.set(a, binding);
122
111
  bindings.set(a, binding);
123
112
  });
124
- // @typedef {Object} BindChain
125
- // @property {Function} to See {@link ~ObservableMixin#_bindTo}.
126
- // @property {Function} toMany See {@link ~ObservableMixin#_bindToMany}.
127
- // @property {module:utils/observablemixin~Observable} _observable The observable which initializes the binding.
128
- // @property {Array} _bindProperties Array of `_observable` properties to be bound.
129
- // @property {Array} _to Array of `to()` observable–properties (`{ observable: toObservable, properties: ...toProperties }`).
130
- // @property {Map} _bindings Stores bindings to be kept in
131
- // {@link ~ObservableMixin#_boundProperties}/{@link ~ObservableMixin#_boundObservables}
132
- // initiated in this binding chain.
133
113
  return {
134
114
  to: bindTo,
135
115
  toMany: bindToMany,
@@ -222,12 +202,11 @@ export default function ObservableMixin(base) {
222
202
  }
223
203
  delete this[decoratedMethods];
224
204
  }
225
- Emitter.prototype.stopListening.call(this, emitter, event, callback);
205
+ super.stopListening(emitter, event, callback);
226
206
  }
227
207
  }
228
208
  return Mixin;
229
209
  }
230
- export const Observable = ObservableMixin(Emitter);
231
210
  // Backward compatibility with `mix`
232
211
  ([
233
212
  'set', 'bind', 'unbind', 'decorate',
@@ -235,28 +214,22 @@ export const Observable = ObservableMixin(Emitter);
235
214
  'stopListening', 'fire', 'delegate', 'stopDelegating',
236
215
  '_addEventListener', '_removeEventListener'
237
216
  ]).forEach(key => {
238
- ObservableMixin[key] = Observable.prototype[key];
217
+ ObservableMixin[key] = defaultObservableClass.prototype[key];
239
218
  });
240
219
  // Init symbol properties needed for the observable mechanism to work.
241
- //
242
- // @private
243
- // @param {module:utils/observablemixin~ObservableMixin} observable
244
220
  function initObservable(observable) {
245
221
  // Do nothing if already inited.
246
222
  if (observable[observablePropertiesSymbol]) {
247
223
  return;
248
224
  }
249
225
  // The internal hash containing the observable's state.
250
- //
251
- // @private
252
- // @type {Map}
253
226
  Object.defineProperty(observable, observablePropertiesSymbol, {
254
227
  value: new Map()
255
228
  });
256
229
  // Map containing bindings to external observables. It shares the binding objects
257
- // (`{ observable: A, property: 'a', to: ... }`) with {@link module:utils/observablemixin~ObservableMixin#_boundProperties} and
230
+ // (`{ observable: A, property: 'a', to: ... }`) with {@link module:utils/observablemixin~Observable#_boundProperties} and
258
231
  // it is used to observe external observables to update own properties accordingly.
259
- // See {@link module:utils/observablemixin~ObservableMixin#bind}.
232
+ // See {@link module:utils/observablemixin~Observable#bind}.
260
233
  //
261
234
  // A.bind( 'a', 'b', 'c' ).to( B, 'x', 'y', 'x' );
262
235
  // console.log( A._boundObservables );
@@ -296,18 +269,16 @@ function initObservable(observable) {
296
269
  // }
297
270
  // } )
298
271
  //
299
- // @private
300
- // @type {Map}
301
272
  Object.defineProperty(observable, boundObservablesSymbol, {
302
273
  value: new Map()
303
274
  });
304
275
  // Object that stores which properties of this observable are bound and how. It shares
305
276
  // the binding objects (`{ observable: A, property: 'a', to: ... }`) with
306
- // {@link module:utils/observablemixin~ObservableMixin#_boundObservables}. This data structure is
307
- // a reverse of {@link module:utils/observablemixin~ObservableMixin#_boundObservables} and it is helpful for
308
- // {@link module:utils/observablemixin~ObservableMixin#unbind}.
277
+ // {@link module:utils/observablemixin~Observable#_boundObservables}. This data structure is
278
+ // a reverse of {@link module:utils/observablemixin~Observable#_boundObservables} and it is helpful for
279
+ // {@link module:utils/observablemixin~Observable#unbind}.
309
280
  //
310
- // See {@link module:utils/observablemixin~ObservableMixin#bind}.
281
+ // See {@link module:utils/observablemixin~Observable#bind}.
311
282
  //
312
283
  // A.bind( 'a', 'b', 'c' ).to( B, 'x', 'y', 'x' );
313
284
  // console.log( A._boundProperties );
@@ -327,17 +298,15 @@ function initObservable(observable) {
327
298
  // c: { observable: A, property: 'c', to: [ [ B, 'x' ] ] },
328
299
  // d: { observable: A, property: 'd', to: [ [ B, 'z' ], [ C, 'w' ] ], callback: callback }
329
300
  // } )
330
- //
331
- // @private
332
- // @type {Map}
333
301
  Object.defineProperty(observable, boundPropertiesSymbol, {
334
302
  value: new Map()
335
303
  });
336
304
  }
337
- // A chaining for {@link module:utils/observablemixin~ObservableMixin#bind} providing `.to()` interface.
338
- //
339
- // @private
340
- // @param {...[Observable|String|Function]} args Arguments of the `.to( args )` binding.
305
+ /**
306
+ * A chaining for {@link module:utils/observablemixin~Observable#bind} providing `.to()` interface.
307
+ *
308
+ * @param args Arguments of the `.to( args )` binding.
309
+ */
341
310
  function bindTo(...args) {
342
311
  const parsedArgs = parseBindToArgs(...args);
343
312
  const bindingsKeys = Array.from(this._bindings.keys());
@@ -389,12 +358,9 @@ function bindTo(...args) {
389
358
  updateBoundObservableProperty(this._observable, propertyName);
390
359
  });
391
360
  }
392
- // Binds to an attribute in a set of iterable observables.
393
- //
394
- // @private
395
- // @param {Array.<Observable>} observables
396
- // @param {String} attribute
397
- // @param {Function} callback
361
+ /**
362
+ * Binds to an attribute in a set of iterable observables.
363
+ */
398
364
  function bindToMany(observables, attribute, callback) {
399
365
  if (this._bindings.size > 1) {
400
366
  /**
@@ -410,43 +376,42 @@ function bindToMany(observables, attribute, callback) {
410
376
  // ...using given callback to parse attribute values.
411
377
  callback);
412
378
  }
413
- // Returns an array of binding components for
414
- // {@link Observable#bind} from a set of iterable observables.
415
- //
416
- // @param {Array.<Observable>} observables
417
- // @param {String} attribute
418
- // @returns {Array.<String|Observable>}
379
+ /**
380
+ * Returns an array of binding components for
381
+ * {@link Observable#bind} from a set of iterable observables.
382
+ */
419
383
  function getBindingTargets(observables, attribute) {
420
384
  const observableAndAttributePairs = observables.map(observable => [observable, attribute]);
421
385
  // Merge pairs to one-dimension array of observables and attributes.
422
386
  return Array.prototype.concat.apply([], observableAndAttributePairs);
423
387
  }
424
- // Check if all entries of the array are of `String` type.
425
- //
426
- // @private
427
- // @param {Array} arr An array to be checked.
428
- // @returns {Boolean}
388
+ /**
389
+ * Check if all entries of the array are of `String` type.
390
+ */
429
391
  function isStringArray(arr) {
430
392
  return arr.every(a => typeof a == 'string');
431
393
  }
432
- // Parses and validates {@link Observable#bind}`.to( args )` arguments and returns
433
- // an object with a parsed structure. For example
434
- //
435
- // A.bind( 'x' ).to( B, 'a', C, 'b', call );
436
- //
437
- // becomes
438
- //
439
- // {
440
- // to: [
441
- // { observable: B, properties: [ 'a' ] },
442
- // { observable: C, properties: [ 'b' ] },
443
- // ],
444
- // callback: call
445
- // }
446
- //
447
- // @private
448
- // @param {...*} args Arguments of {@link Observable#bind}`.to( args )`.
449
- // @returns {Object}
394
+ /**
395
+ * Parses and validates {@link Observable#bind}`.to( args )` arguments and returns
396
+ * an object with a parsed structure. For example
397
+ *
398
+ * ```ts
399
+ * A.bind( 'x' ).to( B, 'a', C, 'b', call );
400
+ * ```
401
+ *
402
+ * becomes
403
+ *
404
+ * ```ts
405
+ * {
406
+ * to: [
407
+ * { observable: B, properties: [ 'a' ] },
408
+ * { observable: C, properties: [ 'b' ] },
409
+ * ],
410
+ * callback: call
411
+ * }
412
+ *
413
+ * @param args Arguments of {@link Observable#bind}`.to( args )`.
414
+ */
450
415
  function parseBindToArgs(...args) {
451
416
  // Eliminate A.bind( 'x' ).to()
452
417
  if (!args.length) {
@@ -476,12 +441,13 @@ function parseBindToArgs(...args) {
476
441
  });
477
442
  return parsed;
478
443
  }
479
- // Synchronizes {@link module:utils/observablemixin#_boundObservables} with {@link Binding}.
480
- //
481
- // @private
482
- // @param {Binding} binding A binding to store in {@link Observable#_boundObservables}.
483
- // @param {Observable} toObservable A observable, which is a new component of `binding`.
484
- // @param {String} toPropertyName A name of `toObservable`'s property, a new component of the `binding`.
444
+ /**
445
+ * Synchronizes {@link module:utils/observable#_boundObservables} with {@link Binding}.
446
+ *
447
+ * @param binding A binding to store in {@link Observable#_boundObservables}.
448
+ * @param toObservable A observable, which is a new component of `binding`.
449
+ * @param toPropertyName A name of `toObservable`'s property, a new component of the `binding`.
450
+ */
485
451
  function updateBoundObservables(observable, binding, toObservable, toPropertyName) {
486
452
  const boundObservables = observable[boundObservablesSymbol];
487
453
  const bindingsToObservable = boundObservables.get(toObservable);
@@ -495,44 +461,53 @@ function updateBoundObservables(observable, binding, toObservable, toPropertyNam
495
461
  boundObservables.set(toObservable, bindings);
496
462
  }
497
463
  }
498
- // Synchronizes {@link Observable#_boundProperties} and {@link Observable#_boundObservables}
499
- // with {@link BindChain}.
500
- //
501
- // Assuming the following binding being created
502
- //
503
- // A.bind( 'a', 'b' ).to( B, 'x', 'y' );
504
- //
505
- // the following bindings were initialized by {@link Observable#bind} in {@link BindChain#_bindings}:
506
- //
507
- // {
508
- // a: { observable: A, property: 'a', to: [] },
509
- // b: { observable: A, property: 'b', to: [] },
510
- // }
511
- //
512
- // Iterate over all bindings in this chain and fill their `to` properties with
513
- // corresponding to( ... ) arguments (components of the binding), so
514
- //
515
- // {
516
- // a: { observable: A, property: 'a', to: [ B, 'x' ] },
517
- // b: { observable: A, property: 'b', to: [ B, 'y' ] },
518
- // }
519
- //
520
- // Then update the structure of {@link Observable#_boundObservables} with updated
521
- // binding, so it becomes:
522
- //
523
- // Map( {
524
- // B: {
525
- // x: Set( [
526
- // { observable: A, property: 'a', to: [ [ B, 'x' ] ] }
527
- // ] ),
528
- // y: Set( [
529
- // { observable: A, property: 'b', to: [ [ B, 'y' ] ] },
530
- // ] )
531
- // }
532
- // } )
533
- //
534
- // @private
535
- // @param {BindChain} chain The binding initialized by {@link Observable#bind}.
464
+ /**
465
+ * Synchronizes {@link Observable#_boundProperties} and {@link Observable#_boundObservables}
466
+ * with {@link BindChain}.
467
+ *
468
+ * Assuming the following binding being created
469
+ *
470
+ * ```ts
471
+ * A.bind( 'a', 'b' ).to( B, 'x', 'y' );
472
+ * ```
473
+ *
474
+ * the following bindings were initialized by {@link Observable#bind} in {@link BindChain#_bindings}:
475
+ *
476
+ * ```ts
477
+ * {
478
+ * a: { observable: A, property: 'a', to: [] },
479
+ * b: { observable: A, property: 'b', to: [] },
480
+ * }
481
+ * ```
482
+ *
483
+ * Iterate over all bindings in this chain and fill their `to` properties with
484
+ * corresponding to( ... ) arguments (components of the binding), so
485
+ *
486
+ * ```ts
487
+ * {
488
+ * a: { observable: A, property: 'a', to: [ B, 'x' ] },
489
+ * b: { observable: A, property: 'b', to: [ B, 'y' ] },
490
+ * }
491
+ * ```
492
+ *
493
+ * Then update the structure of {@link Observable#_boundObservables} with updated
494
+ * binding, so it becomes:
495
+ *
496
+ * ```ts
497
+ * Map( {
498
+ * B: {
499
+ * x: Set( [
500
+ * { observable: A, property: 'a', to: [ [ B, 'x' ] ] }
501
+ * ] ),
502
+ * y: Set( [
503
+ * { observable: A, property: 'b', to: [ [ B, 'y' ] ] },
504
+ * ] )
505
+ * }
506
+ * } )
507
+ * ```
508
+ *
509
+ * @param chain The binding initialized by {@link Observable#bind}.
510
+ */
536
511
  function updateBindToBound(chain) {
537
512
  let toProperty;
538
513
  chain._bindings.forEach((binding, propertyName) => {
@@ -546,12 +521,13 @@ function updateBindToBound(chain) {
546
521
  });
547
522
  });
548
523
  }
549
- // Updates an property of a {@link Observable} with a value
550
- // determined by an entry in {@link Observable#_boundProperties}.
551
- //
552
- // @private
553
- // @param {Observable} observable A observable which property is to be updated.
554
- // @param {String} propertyName An property to be updated.
524
+ /**
525
+ * Updates an property of a {@link Observable} with a value
526
+ * determined by an entry in {@link Observable#_boundProperties}.
527
+ *
528
+ * @param observable A observable which property is to be updated.
529
+ * @param propertyName An property to be updated.
530
+ */
555
531
  function updateBoundObservableProperty(observable, propertyName) {
556
532
  const boundProperties = observable[boundPropertiesSymbol];
557
533
  const binding = boundProperties.get(propertyName);
@@ -575,13 +551,13 @@ function updateBoundObservableProperty(observable, propertyName) {
575
551
  observable.set(propertyName, propertyValue);
576
552
  }
577
553
  }
578
- // Starts listening to changes in {@link BindChain._to} observables to update
579
- // {@link BindChain._observable} {@link BindChain._bindProperties}. Also sets the
580
- // initial state of {@link BindChain._observable}.
581
- //
582
- // @private
583
- // @param {Observable} observable
584
- // @param {BindChain} chain The chain initialized by {@link Observable#bind}.
554
+ /**
555
+ * Starts listening to changes in {@link BindChain._to} observables to update
556
+ * {@link BindChain._observable} {@link BindChain._bindProperties}. Also sets the
557
+ * initial state of {@link BindChain._observable}.
558
+ *
559
+ * @param chain The chain initialized by {@link Observable#bind}.
560
+ */
585
561
  function attachBindToListeners(observable, toBindings) {
586
562
  toBindings.forEach(to => {
587
563
  const boundObservables = observable[boundObservablesSymbol];
package/src/priorities.js CHANGED
@@ -4,17 +4,8 @@
4
4
  */
5
5
  /**
6
6
  * Provides group of constants to use instead of hardcoding numeric priority values.
7
- *
8
- * @namespace
9
7
  */
10
8
  const priorities = {
11
- /**
12
- * Converts a string with priority name to it's numeric value. If `Number` is given, it just returns it.
13
- *
14
- * @static
15
- * @param {module:utils/priorities~PriorityString} [priority] Priority to convert.
16
- * @returns {Number} Converted priority.
17
- */
18
9
  get(priority = 'normal') {
19
10
  if (typeof priority != 'number') {
20
11
  return this[priority] || this.normal;
@@ -12,19 +12,20 @@ const BIG_CHUNK_SIZE = 10000;
12
12
  *
13
13
  * Note: in contrary to Array.splice, this function does not modify the original `target`.
14
14
  *
15
- * spliceArray( [ 1, 2 ], [ 3, 4 ], 0, 0 ); // [ 3, 4, 1, 2 ]
16
- * spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 1 ); // [ 1, 3, 4 ]
17
- * spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 0 ); // [ 1, 3, 4, 2 ]
18
- * spliceArray( [ 1, 2 ], [ 3, 4 ], 2, 0 ); // [ 1, 2, 3, 4 ]
19
- * spliceArray( [ 1, 2 ], [], 0, 1 ); // [ 2 ]
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
+ * ```
20
22
  *
21
- * @private
22
- * @param {Array} target Array to be spliced.
23
- * @param {Array} source Array of elements to be inserted to target.
24
- * @param {Number} start Index at which nodes should be inserted/removed.
25
- * @param {Number} count Number of items.
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.
26
27
  *
27
- * @returns {Array} New spliced array.
28
+ * @returns New spliced array.
28
29
  */
29
30
  export default function spliceArray(target, source, start, count) {
30
31
  // In case of performance problems, see: https://github.com/ckeditor/ckeditor5/pull/12429/files#r965850568
package/src/spy.js CHANGED
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * * spy.called: property set to `true` if the function has been called at least once.
14
14
  *
15
- * @returns {Function} The spy function.
15
+ * @returns The spy function.
16
16
  */
17
17
  function spy() {
18
18
  return function spy() {
package/src/tomap.js CHANGED
@@ -10,12 +10,14 @@ import isIterable from './isiterable';
10
10
  /**
11
11
  * Transforms object or iterable to map. Iterable needs to be in the format acceptable by the `Map` constructor.
12
12
  *
13
- * map = toMap( { 'foo': 1, 'bar': 2 } );
14
- * map = toMap( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
15
- * map = toMap( anotherMap );
13
+ * ```ts
14
+ * map = toMap( { 'foo': 1, 'bar': 2 } );
15
+ * map = toMap( [ [ 'foo', 1 ], [ 'bar', 2 ] ] );
16
+ * map = toMap( anotherMap );
17
+ * ```
16
18
  *
17
- * @param {Object|Iterable|null} data Object or iterable to transform.
18
- * @returns {Map} Map created from data.
19
+ * @param data Object or iterable to transform.
20
+ * @returns Map created from data.
19
21
  */
20
22
  export default function toMap(data) {
21
23
  if (isIterable(data)) {