Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
use for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored and lukastaegert committed May 7, 2018
1 parent 3dedacd commit 5f40964
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dataToEsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export default function dataToNamedExports ( data, options = {} ) {

let namedExportCode = '';
const defaultExportRows = [];
Object.keys( data ).forEach(key => {
const dataKeys = Object.keys( data );
for (let i = 0; i < dataKeys.length; i++) {
const key = dataKeys[i];
if (key === makeLegalIdentifier( key )) {
if ( options.objectShorthand )
defaultExportRows.push(key);
Expand All @@ -20,6 +22,6 @@ export default function dataToNamedExports ( data, options = {} ) {
} else {
defaultExportRows.push( `${ JSON.stringify(key) }: ${ tosource( data[key], null, options.compact ? false : t )}` );
}
});
}
return namedExportCode + `export default${ _ }{${ n }${ t }${ defaultExportRows.join(`,${ n }${ t }`) }${ n }};${ n }`;
};

0 comments on commit 5f40964

Please sign in to comment.