{"id":15083843,"url":"https://github.com/bastidood/js-generators-vs-array-methods","last_synced_at":"2026-01-04T03:08:36.741Z","repository":{"id":256102959,"uuid":"854143838","full_name":"BastiDood/js-generators-vs-array-methods","owner":"BastiDood","description":"The repository for all the scripts, notebooks, results, and analyses related to my experiments on JavaScript generators and chained array methods.","archived":false,"fork":false,"pushed_at":"2024-09-09T01:18:30.000Z","size":1060,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T08:35:51.178Z","etag":null,"topics":["bun","deno","javascript","node","notebook","python"],"latest_commit_sha":null,"homepage":"https://dev.to/somedood/i-was-wrong-about-array-methods-and-generators-2ig9","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BastiDood.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-08T13:49:06.000Z","updated_at":"2024-09-16T06:00:11.000Z","dependencies_parsed_at":"2024-09-09T02:36:54.198Z","dependency_job_id":"d9c491c3-8098-4196-9dbf-2fa80829466e","html_url":"https://github.com/BastiDood/js-generators-vs-array-methods","commit_stats":null,"previous_names":["bastidood/js-generators-vs-array-methods"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fjs-generators-vs-array-methods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fjs-generators-vs-array-methods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fjs-generators-vs-array-methods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BastiDood%2Fjs-generators-vs-array-methods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BastiDood","download_url":"https://codeload.github.com/BastiDood/js-generators-vs-array-methods/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243941499,"owners_count":20372248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","deno","javascript","node","notebook","python"],"created_at":"2024-09-25T06:33:49.968Z","updated_at":"2026-01-04T03:08:36.702Z","avatar_url":"https://github.com/BastiDood.png","language":"Jupyter Notebook","readme":"# JavaScript Generators vs. Array Methods\n\nThe repository for all the scripts, notebooks, results, and analyses related to my experiments on JavaScript generators and chained array methods. See the full article [\"I was wrong about array methods and generators...\"][article] for more details on the methodology, results, interpretations, and conclusions.\n\n[article]: https://dev.to/somedood/i-was-wrong-about-array-methods-and-generators-2ig9\n\n## Generating Random Bytes\n\nThe first step is to generate 32 KiB of random data. There are many ways to do this, but I opted to generate them via the [`Crypto#getRandomValues`] function in JavaScript. A Deno script is already available at [`random/random.js`].\n\n[`Crypto#getRandomValues`]: https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\n[`random/random.js`]: random/random.js\n\n```bash\n# This will overwrite the already existing `random.bin` file!\ndeno run random/random.js\n```\n\n## Running the Experiments\n\n```bash\n# Node.js\nfunction run () { node --experimental-default-type=module benchmark/bench.node.js $1 \u003e notebook/node/$1.csv; }\nrun raw-for-loop\nrun for-of-loop\nrun array-method\nrun generator\n```\n\n```bash\n# Deno\nfunction run () { deno --quiet --allow-read --allow-hrtime benchmark/bench.deno.js -- $1 \u003e notebook/deno/$1.csv; }\nrun raw-for-loop\nrun for-of-loop\nrun array-method\nrun generator\n```\n\n```bash\n# Bun\nfunction run () { bun --silent benchmark/bench.bun.js $1 \u003e notebook/bun/$1.csv; }\nrun raw-for-loop\nrun for-of-loop\nrun array-method\nrun generator\n```\n\n## Analyzing the Data\n\nThe Python notebook containing the data analysis is located at [`notebook/analysis.ipynb`].\n\n[`notebook/analysis.ipynb`]: notebook/analysis.ipynb\n\n```bash\nconda env create --file notebook/environment.yml\nconda activate js-generators-vs-array-methods\n# You may now run the Python notebook.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbastidood%2Fjs-generators-vs-array-methods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbastidood%2Fjs-generators-vs-array-methods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbastidood%2Fjs-generators-vs-array-methods/lists"}