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

Merge pull request #79 from ckeditor/t/55

Editor should throw if config.creator is not set
Piotr Jasiun 10 лет назад
Родитель
Сommit
860c189c4d
1 измененных файлов с 18 добавлено и 0 удалено
  1. 18 0
      packages/ckeditor5-ui/src/utils.js

+ 18 - 0
packages/ckeditor5-ui/src/utils.js

@@ -89,6 +89,24 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], ( lodashInclu
 				// Compared array is longer so it is a suffix of the other array.
 				return utils.compareArrays.EXTENSION;
 			}
+		},
+
+		/**
+		 * Returns `nth` (starts from `0` of course) item of an `iterable`.
+		 *
+		 * @param {Number} index
+		 * @param {Iterable.<*>} iterable
+		 * @returns {*}
+		 */
+		nth( index, iterable ) {
+			for ( let item of iterable ) {
+				if ( index === 0 ) {
+					return item;
+				}
+				index -= 1;
+			}
+
+			return null;
 		}
 	};