Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 1fdf2f1

Browse files
authored
Merge pull request #316 from ckeditor/context
Feature: Added iterator interface to the `Config` class.
2 parents 2175c69 + c38d06b commit 1fdf2f1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ export default class Config {
113113
return this._getFromSource( this._config, name );
114114
}
115115

116+
/**
117+
* Iterates over all top level configuration names.
118+
*
119+
* @returns {Iterable.<String>}
120+
*/
121+
* names() {
122+
for ( const name of Object.keys( this._config ) ) {
123+
yield name;
124+
}
125+
}
126+
116127
/**
117128
* Saves passed configuration to the specified target (nested object).
118129
*

tests/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,10 @@ describe( 'Config', () => {
459459
expect( nodesAgain ).to.deep.equal( nodes );
460460
} );
461461
} );
462+
463+
describe( 'names()', () => {
464+
it( 'should return an iterator of top level names of the configuration', () => {
465+
expect( Array.from( config.names() ) ).to.be.deep.equal( [ 'creator', 'language', 'resize', 'toolbar', 'options' ] );
466+
} );
467+
} );
462468
} );

0 commit comments

Comments
 (0)