8
0
Просмотр исходного кода

Internal: Used a cheaper type check, to increase performance.

The toMap function is used during view element creation (which happens a lot) and lodash's isPlainObject method is pretty expensive.
Marek Lewandowski 6 лет назад
Родитель
Сommit
809ba77c2a
1 измененных файлов с 4 добавлено и 4 удалено
  1. 4 4
      packages/ckeditor5-utils/src/tomap.js

+ 4 - 4
packages/ckeditor5-utils/src/tomap.js

@@ -8,7 +8,7 @@
  */
 
 import objectToMap from './objecttomap';
-import { isPlainObject } from 'lodash-es';
+import isIterable from './isiterable';
 
 /**
  * Transforms object or iterable to map. Iterable needs to be in the format acceptable by the `Map` constructor.
@@ -21,9 +21,9 @@ import { isPlainObject } from 'lodash-es';
  * @returns {Map} Map created from data.
  */
 export default function toMap( data ) {
-	if ( isPlainObject( data ) ) {
-		return objectToMap( data );
-	} else {
+	if ( isIterable( data ) ) {
 		return new Map( data );
+	} else {
+		return objectToMap( data );
 	}
 }