瀏覽代碼

Implementation for PluginCollection.destroy() is more readable.

Kamil Piechaczek 8 年之前
父節點
當前提交
00e44f2860
共有 1 個文件被更改,包括 4 次插入7 次删除
  1. 4 7
      packages/ckeditor5-core/src/plugincollection.js

+ 4 - 7
packages/ckeditor5-core/src/plugincollection.js

@@ -213,13 +213,10 @@ export default class PluginCollection {
 	 * @returns {Promise}
 	 */
 	destroy() {
-		const promises = [];
-
-		for ( const [ , pluginInstance ] of this ) {
-			if ( typeof pluginInstance.destroy == 'function' ) {
-				promises.push( pluginInstance.destroy() );
-			}
-		}
+		const promises = Array.from( this )
+			.map( ( [ , pluginInstance ] ) => pluginInstance )
+			.filter( pluginInstance => typeof pluginInstance.destroy == 'function' )
+			.map( pluginInstance => pluginInstance.destroy() );
 
 		return Promise.all( promises );
 	}