@best/runtime
Advanced tools
Comparing version 4.0.0-alpha4 to 4.0.0-alpha5
const BEFORE_ALL = 'beforeAll'; | ||
const BEFORE_EACH = 'beforeEach'; | ||
const BEFORE = 'before'; | ||
const AFTER_ALL = 'afterAll'; | ||
const AFTER_EACH = 'afterEach'; | ||
const AFTER = 'after'; | ||
@@ -12,6 +10,4 @@ const MODE_ONLY = 'only'; | ||
BEFORE_ALL, | ||
BEFORE_EACH, | ||
BEFORE, | ||
AFTER_ALL, | ||
AFTER_EACH, | ||
AFTER, | ||
@@ -18,0 +14,0 @@ }; |
@@ -26,4 +26,6 @@ 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.`, | ||
); | ||
} | ||
@@ -57,2 +59,2 @@ if (currentDescribeBlock.parent) { | ||
export default handler; | ||
//# sourceMappingURL=primitives-handler.js.map | ||
//# sourceMappingURL=primitives-handler.js.map |
@@ -21,9 +21,7 @@ import { dispatch } from './state'; | ||
const beforeAll = (fn) => _addHook(fn, HOOKS.BEFORE_ALL); | ||
const beforeEach = (fn) => _addHook(fn, HOOKS.BEFORE_EACH); | ||
const before = (fn) => _addHook(fn, HOOKS.BEFORE); | ||
const afterAll = (fn) => _addHook(fn, HOOKS.AFTER_ALL); | ||
const afterEach = (fn) => _addHook(fn, HOOKS.AFTER_EACH); | ||
const after = (fn) => _addHook(fn, HOOKS.AFTER); | ||
const run = (fn) => dispatch({ nodeName: 'run', fn, nodeType: RUN_BENCHMARK }); | ||
export { describe, benchmark, beforeAll, beforeEach, before, afterAll, afterEach, after, run }; | ||
export { describe, benchmark, beforeAll, before, afterAll, after, run }; | ||
//# sourceMappingURL=primitives.js.map |
@@ -10,2 +10,2 @@ export function normalizeResults(benchmarkState) { | ||
} | ||
//# sourceMappingURL=results.js.map | ||
//# sourceMappingURL=results.js.map |
@@ -69,6 +69,2 @@ import { raf, time, nextTick, withMacroTask, formatTime } from './utils/timers'; | ||
for (const child of children) { | ||
// -- Before Each ---- | ||
for (const hook of hookHandlers[HOOKS.BEFORE_EACH]) { | ||
await hook(); | ||
} | ||
// -- Traverse Child ---- | ||
@@ -78,6 +74,2 @@ node.startedAt = formatTime(time()); | ||
node.aggregate = formatTime(time() - node.startedAt); | ||
// -- After Each Child ---- | ||
for (const hook of hookHandlers[HOOKS.AFTER_EACH]) { | ||
await hook(); | ||
} | ||
} | ||
@@ -84,0 +76,0 @@ } |
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,7 +31,6 @@ 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,7 +34,8 @@ /* | ||
}; | ||
} | ||
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(); | ||
@@ -46,4 +47,3 @@ const port = channel.port2; | ||
}; | ||
} | ||
else { | ||
} else { | ||
/* istanbul ignore next */ | ||
@@ -61,4 +61,3 @@ macroTimerFunc = () => { | ||
}; | ||
} | ||
else { | ||
} else { | ||
// fallback to macro | ||
@@ -72,4 +71,5 @@ microTimerFunc = macroTimerFunc; | ||
export function withMacroTask(fn) { | ||
return (fn._withTask || | ||
(fn._withTask = function () { | ||
return ( | ||
fn._withTask || | ||
(fn._withTask = function() { | ||
useMacroTask = true; | ||
@@ -79,3 +79,4 @@ const res = fn.apply(null, arguments); | ||
return res; | ||
})); | ||
}) | ||
); | ||
} | ||
@@ -88,8 +89,6 @@ export function nextTick(cb, ctx) { | ||
cb.call(ctx); | ||
} | ||
catch (e) { | ||
} catch (e) { | ||
handleError(e, ctx, 'nextTick'); | ||
} | ||
} | ||
else if (_resolve) { | ||
} else if (_resolve) { | ||
_resolve(ctx); | ||
@@ -102,14 +101,15 @@ } | ||
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-alpha4", | ||
"version": "4.0.0-alpha5", | ||
"description": "Best Runtime", | ||
@@ -20,3 +20,3 @@ "keywords": [ | ||
], | ||
"gitHead": "090748b5a0cdffc678de5f5fda4d056e245a24ca" | ||
"gitHead": "9171538bbf3edaca3eb0b6f470b119a269b7779e" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18099
490