You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
My general feeling about this package is that it feels like it has been created 20 years ago. No UMD module, strange export mechanism, there's a single source file which is a giant hairball of 2000+ lines of code... It is very unfriendly to the modern JavaScript development stack.
So I've only tried with Rollup but it has been quite hard to bundle Benchmark into something that can run in the browser. Thought you might be interested in including this little wrapper for those who are using module bundler:
TypeScript:
import_from'lodash'importBenchmarkfrom'benchmark'// avoid `Cannot read property 'parentNode' of undefined` error in runScriptconstscript=document.createElement('script')document.body.appendChild(script)// Benchmark could not pick up lodash otherwiseconstbm: any=Benchmark.runInContext({ _ })// avoid `ReferenceError: Benchmark is not defined` error because Benchmark is assumed to be in windowconstwin=windowasanywin.Benchmark=bmexportdefaultbm
ES2015:
import_from'lodash'importBenchmarkfrom'benchmark'// avoid `Cannot read property 'parentNode' of undefined` error in runScriptconstscript=document.createElement('script')document.body.appendChild(script)// Benchmark could not pick up lodash otherwiseconstbm=Benchmark.runInContext({ _ })// avoid `ReferenceError: Benchmark is not defined` error because Benchmark is assumed to be in windowwindow.Benchmark=bmexportdefaultbm
The text was updated successfully, but these errors were encountered:
Just a little Typescript alternative without the anys:
import_from'lodash';importBenchmarkfrom'benchmark';// declare the global propertydeclare global {interfaceWindow{Benchmark: typeofBenchmark;}}// avoid `Cannot read property 'parentNode' of undefined` error in runScriptconstscript=document.createElement('script');document.body.appendChild(script);// cast the faulty `Function` typewindow.Benchmark=Benchmark.runInContext({ _ })astypeofBenchmark;// provide scoped constructorexportdefaultwindow.Benchmark;
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
My general feeling about this package is that it feels like it has been created 20 years ago. No UMD module, strange export mechanism, there's a single source file which is a giant hairball of 2000+ lines of code... It is very unfriendly to the modern JavaScript development stack.
So I've only tried with Rollup but it has been quite hard to bundle Benchmark into something that can run in the browser. Thought you might be interested in including this little wrapper for those who are using module bundler:
TypeScript:
ES2015:
The text was updated successfully, but these errors were encountered: