Browse Source

Fix lint

gh-953
Bogdan Chadkin 8 years ago
parent
commit
50d263203e
  1. 2
      src/rollup.js
  2. 12
      src/utils/flushTime.js

2
src/rollup.js

@ -61,7 +61,7 @@ export function rollup ( options ) {
timeEnd( '--BUILD--' ); timeEnd( '--BUILD--' );
function generate ( options ) { function generate ( options ) {
timeStart( '--GENERATE--' ) timeStart( '--GENERATE--' );
const rendered = bundle.render( options ); const rendered = bundle.render( options );

12
src/utils/flushTime.js

@ -1,7 +1,7 @@
const DEBUG = false; const DEBUG = false;
const map = new Map; const map = new Map;
export function timeStart( label ) { export function timeStart ( label ) {
if ( !map.has( label ) ) { if ( !map.has( label ) ) {
map.set( label, { map.set( label, {
time: 0 time: 0
@ -10,26 +10,28 @@ export function timeStart( label ) {
map.get( label ).start = process.hrtime(); map.get( label ).start = process.hrtime();
} }
export function timeEnd( label ) { export function timeEnd ( label ) {
if ( map.has( label ) ) { if ( map.has( label ) ) {
const item = map.get( label ); const item = map.get( label );
item.time += toMilliseconds( process.hrtime( item.start ) ); item.time += toMilliseconds( process.hrtime( item.start ) );
} }
} }
export function flushTime( log = defaultLog ) { export function flushTime ( log = defaultLog ) {
for ( const item of map.entries() ) { for ( const item of map.entries() ) {
log( item[0], item[1].time ); log( item[0], item[1].time );
} }
map.clear(); map.clear();
} }
function toMilliseconds( time ) { function toMilliseconds ( time ) {
return time[0] * 1e+3 + Math.floor( time[1] * 1e-6 ); return time[0] * 1e+3 + Math.floor( time[1] * 1e-6 );
} }
function defaultLog( label, time ) { function defaultLog ( label, time ) {
if ( DEBUG ) { if ( DEBUG ) {
/* eslint-disable no-console */
console.info( '%dms: %s', time, label ); console.info( '%dms: %s', time, label );
/* eslint-enable no-console */
} }
} }

Loading…
Cancel
Save