{"id":21991571,"url":"https://github.com/benoitzohar/replx","last_synced_at":"2025-04-30T13:52:00.139Z","repository":{"id":34909802,"uuid":"188484112","full_name":"benoitzohar/replx","owner":"benoitzohar","description":"REPLx - A REPL CLI tool on steroids","archived":false,"fork":false,"pushed_at":"2023-01-04T21:46:40.000Z","size":676,"stargazers_count":4,"open_issues_count":10,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-20T22:20:12.325Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benoitzohar.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}},"created_at":"2019-05-24T20:33:15.000Z","updated_at":"2020-11-17T21:35:10.000Z","dependencies_parsed_at":"2023-01-15T10:14:33.981Z","dependency_job_id":null,"html_url":"https://github.com/benoitzohar/replx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitzohar%2Freplx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitzohar%2Freplx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitzohar%2Freplx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitzohar%2Freplx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benoitzohar","download_url":"https://codeload.github.com/benoitzohar/replx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251714939,"owners_count":21631806,"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":[],"created_at":"2024-11-29T20:09:55.574Z","updated_at":"2025-04-30T13:52:00.100Z","avatar_url":"https://github.com/benoitzohar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REPLx - A REPL CLI tool on steroids \n\n[![npm version](https://img.shields.io/npm/v/@benoitzohar/replx.svg)](https://www.npmjs.com/package/@benoitzohar/replx)\n[![Build Status](https://travis-ci.org/benoitzohar/replx.svg?branch=master)](https://travis-ci.org/benoitzohar/replx)\n[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/25ca409490cd4caeb25a80fb85cab28f)](https://www.codacy.com/app/benoit.zohar/replx?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=benoitzohar/replx\u0026utm_campaign=Badge_Coverage)\n\n_\"Read-Eval-Print-Loop-**times**\"_ allows you to run a Javascript code with node and monitor the execution time for as many executions as you want.\n\n## Installation\n\nYou may want to install _replx_ globally to be able to use it wherever you want:\n\n```bash\nnpm i -g @benoitzohar/replx\n```\n\n## Usage\n\n`replx [options] \u003csource\u003e [times]`\n\nRun an inline script:\n\n```bash\n$ replx \"console.log('hello')\" 3\n hello\n hello\n hello\n [Inline code] 1.312974ms\n```\n\nor load a file:\n\n```bash\n$ replx myfile.js\n oh hello\n [myfile.js] 1.3433752ms\n```\n\nYou can watch for file changes and rerun replx everytime:\n\n```bash\n$ replx --watch myfile.js\n```\n\nor\n\n```bash\n$ replx -w myfile.js\n```\n\n### Comparison\n\nTo compare multiple functions, you can create a file that **exports** as many function as you'd like and `replx` will compare the time for you. For example:\n\n```js\nconst base = \"Lorem ipsum dolor sit amet, mea dolor placerat consectetuer ut\";\n\nmodule.exports.A = () =\u003e {\n  const res = [];\n  base.split().forEach(c =\u003e res.push(c.toUpperCase()));\n  return res;\n};\n\nmodule.exports.B = () =\u003e {\n  const res = base.split().map(c =\u003e c.toUpperCase());\n  return res;\n};\n```\n\n### Run multiple times\n\nOf course, one run is not enough to determine which function is faster, so you can easily tell `replx` to run you code multiple time.\nFor example, here we will run the code for each functions in the file 1000000 times:\n\n```bash\n$ replx myfile.js 1000000\n```\n\nNote that the returned value of each function will **not** be logged if you run the code multiple times.\n\n### Create\n\nYou can create an empty file automatically if it doesn't exist:\n\n```bash\n$ replx --create myfile.js\n```\n\nor\n\n```bash\n$ replx -c myfile.js\n```\n\nSince the file will be empty by default, we suggest that you use `-c` along with `-w` so you can use `replx -c -w myfile.js` and start measuring right away.\n\nIf you want to make a comparison, you can create a file with 2 exported functions:\n\n```bash\n$ replx --comparison myfile.js\n```\n\nor\n\n```bash\n$ replx -k myfile.js\n```\n\n## Example\n\n\n```bash\n$ replx -k -w myfile.js 1000\n[B] 0.08004ms\n[A] 0.098599ms (1x slower)\n---\n[A] 0.086088ms\n[B] 0.166884ms (2x slower)\n```\n\nThis command will:\n\n- create the file `myfile.js` with 2 exports functions:\n\n```js\nmodule.exports.A = () =\u003e {\n  return \"A\";\n};\n\nmodule.exports.B = () =\u003e {\n  return \"B\";\n};\n```\n\n- open it in your default IDE (based on the file extension)\n- run the code 1000 times for each function\n- compare the time between the two functions\n- watch for file change and re-run, etc.\n\n## Help\n\nUse `replx` or `replx -h` for help.\n\n## Notes\n\nFor now, if you use replx as an inline script, be aware that the timing includes the cost of `eval()` at each loop. This means that the _time to run_ displayed is not _exactly_ the time to run your script.  \nIn the same spirit, if you use a file, the cached cost of `require()` will be included.\n\nHowever, using `replx` to compare the time-to-run of two different scripts will work as expected since the `require` cost will be the same in all the variants.\n\nThe run time can vary greatly between runs, we suggest that you run `replx` more than once to ensure the results are aligned.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitzohar%2Freplx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoitzohar%2Freplx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitzohar%2Freplx/lists"}