@best/runtime
Advanced tools
Comparing version 4.0.0-alpha5 to 4.0.0-alpha6
@@ -26,6 +26,4 @@ import { makeDescribe, makeBenchmark, makeBenchmarkRun } from './utils/primitives-nodes'; | ||
} | ||
if (currentDescribeBlock.type === 'benchmark' && !currentDescribeBlock.run) { | ||
throw new Error( | ||
`Benchmark "${currentDescribeBlock.name}" must have a 'run()' function or contain benchmarks inside.`, | ||
); | ||
if (currentDescribeBlock.type === "benchmark" && !currentDescribeBlock.run) { | ||
throw new Error(`Benchmark "${currentDescribeBlock.name}" must have a 'run()' function or contain benchmarks inside.`); | ||
} | ||
@@ -59,2 +57,2 @@ if (currentDescribeBlock.parent) { | ||
export default handler; | ||
//# sourceMappingURL=primitives-handler.js.map | ||
//# sourceMappingURL=primitives-handler.js.map |
@@ -10,2 +10,2 @@ export function normalizeResults(benchmarkState) { | ||
} | ||
//# sourceMappingURL=results.js.map | ||
//# sourceMappingURL=results.js.map |
import primitivesHandler from './primitives-handler'; | ||
import { makeDescribe } from './utils/primitives-nodes'; | ||
import DEFAULT_STATE from './utils/default-state'; | ||
import cloneState from './utils/clone-state'; | ||
import cloneState from "./utils/clone-state"; | ||
const eventHandlers = [primitivesHandler]; | ||
@@ -14,3 +14,3 @@ const ROOT_DESCRIBE_BLOCK_NAME = typeof BEST_CONFIG !== 'undefined' ? BEST_CONFIG.benchmarkName : 'ROOT_DESCRIBE_BLOCK'; | ||
export const getBenchmarkRootNode = () => getBenckmarkState().rootDescribeBlock; | ||
export const initializeBenchmarkConfig = newOpts => { | ||
export const initializeBenchmarkConfig = (newOpts) => { | ||
if (newOpts.iterations !== undefined) { | ||
@@ -31,6 +31,7 @@ if (newOpts.iterateOnClient === undefined) { | ||
} | ||
} catch (err) { | ||
} | ||
catch (err) { | ||
STATE.benchmarkDefinitionError = err; | ||
} | ||
} | ||
//# sourceMappingURL=state.js.map | ||
//# sourceMappingURL=state.js.map |
export default function cloneState(obj) { | ||
const stateClone = Object.assign({}, obj); | ||
if (stateClone.children) { | ||
stateClone.children = stateClone.children.map(obj => cloneState(obj)); | ||
stateClone.children = stateClone.children.map((obj) => cloneState(obj)); | ||
} | ||
@@ -11,2 +11,2 @@ if (stateClone.run) { | ||
} | ||
//# sourceMappingURL=clone-state.js.map | ||
//# sourceMappingURL=clone-state.js.map |
export default Object.freeze({ | ||
benchmarkName: '', | ||
benchmarkName: "", | ||
useMacroTaskAfterBenchmark: true, | ||
@@ -11,2 +11,2 @@ maxDuration: 1000 * 20, | ||
}); | ||
//# sourceMappingURL=default-state.js.map | ||
//# sourceMappingURL=default-state.js.map |
@@ -34,8 +34,7 @@ /* | ||
}; | ||
} else if ( | ||
typeof MessageChannel !== 'undefined' && | ||
} | ||
else if (typeof MessageChannel !== 'undefined' && | ||
(isNative(MessageChannel) || | ||
// PhantomJS | ||
MessageChannel.toString() === '[object MessageChannelConstructor]') | ||
) { | ||
MessageChannel.toString() === '[object MessageChannelConstructor]')) { | ||
const channel = new MessageChannel(); | ||
@@ -47,3 +46,4 @@ const port = channel.port2; | ||
}; | ||
} else { | ||
} | ||
else { | ||
/* istanbul ignore next */ | ||
@@ -61,3 +61,4 @@ macroTimerFunc = () => { | ||
}; | ||
} else { | ||
} | ||
else { | ||
// fallback to macro | ||
@@ -71,5 +72,4 @@ microTimerFunc = macroTimerFunc; | ||
export function withMacroTask(fn) { | ||
return ( | ||
fn._withTask || | ||
(fn._withTask = function() { | ||
return (fn._withTask || | ||
(fn._withTask = function () { | ||
useMacroTask = true; | ||
@@ -79,4 +79,3 @@ const res = fn.apply(null, arguments); | ||
return res; | ||
}) | ||
); | ||
})); | ||
} | ||
@@ -89,6 +88,8 @@ export function nextTick(cb, ctx) { | ||
cb.call(ctx); | ||
} catch (e) { | ||
} | ||
catch (e) { | ||
handleError(e, ctx, 'nextTick'); | ||
} | ||
} else if (_resolve) { | ||
} | ||
else if (_resolve) { | ||
_resolve(ctx); | ||
@@ -101,15 +102,14 @@ } | ||
macroTimerFunc(); | ||
} else { | ||
} | ||
else { | ||
microTimerFunc(); | ||
} | ||
} | ||
return cb | ||
? null | ||
: new Promise(resolve => { | ||
_resolve = resolve; | ||
}); | ||
return cb ? null : new Promise(resolve => { | ||
_resolve = resolve; | ||
}); | ||
} | ||
export const time = window.performance.now.bind(window.performance); | ||
export const formatTime = t => Math.round(t * 1000) / 1000; | ||
export const formatTime = (t) => Math.round(t * 1000) / 1000; | ||
export const raf = window && window.requestAnimationFrame ? window.requestAnimationFrame : nextTick; | ||
//# sourceMappingURL=timers.js.map | ||
//# sourceMappingURL=timers.js.map |
@@ -13,2 +13,2 @@ export function validateState(benchmarkState) { | ||
} | ||
//# sourceMappingURL=validate.js.map | ||
//# sourceMappingURL=validate.js.map |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "4.0.0-alpha5", | ||
"version": "4.0.0-alpha6", | ||
"description": "Best Runtime", | ||
@@ -20,3 +20,3 @@ "keywords": [ | ||
], | ||
"gitHead": "9171538bbf3edaca3eb0b6f470b119a269b7779e" | ||
"gitHead": "790688e72822f83bdd0ccf304b522784fe35dd94" | ||
} |
18044
482