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

Commit

Permalink
Merge pull request #316 from ckeditor/context
Browse files Browse the repository at this point in the history
Feature: Added iterator interface to the `Config` class.
  • Loading branch information
scofalik authored Dec 16, 2019
2 parents 2175c69 + c38d06b commit 1fdf2f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ export default class Config {
return this._getFromSource( this._config, name );
}

/**
* Iterates over all top level configuration names.
*
* @returns {Iterable.<String>}
*/
* names() {
for ( const name of Object.keys( this._config ) ) {
yield name;
}
}

/**
* Saves passed configuration to the specified target (nested object).
*
Expand Down
6 changes: 6 additions & 0 deletions tests/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,10 @@ describe( 'Config', () => {
expect( nodesAgain ).to.deep.equal( nodes );
} );
} );

describe( 'names()', () => {
it( 'should return an iterator of top level names of the configuration', () => {
expect( Array.from( config.names() ) ).to.be.deep.equal( [ 'creator', 'language', 'resize', 'toolbar', 'options' ] );
} );
} );
} );

0 comments on commit 1fdf2f1

Please sign in to comment.