utils.js 841 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* globals window */
  6. /**
  7. * Loads a predefined set of performance markup files.
  8. *
  9. * loadPerformanceData()
  10. * .then( fixtures => {
  11. * window.editor.setData( fixtures.small );
  12. * } );
  13. *
  14. * @returns {Promise.<Object.<String, String>>}
  15. */
  16. export function loadPerformanceData() {
  17. return Promise.all( [ getFileContents( 'small' ), getFileContents( 'medium' ), getFileContents( 'large' ) ] )
  18. .then( responses => {
  19. return {
  20. small: responses[ 0 ],
  21. medium: responses[ 1 ],
  22. large: responses[ 2 ]
  23. };
  24. } );
  25. function getFileContents( fileName ) {
  26. return window.fetch( `_utils/${ fileName }.txt` )
  27. .then( resp => resp.text() );
  28. }
  29. }