{"id":18303551,"url":"https://github.com/sina-byn/comment-eraser","last_synced_at":"2026-05-09T05:34:58.015Z","repository":{"id":182248958,"uuid":"668172442","full_name":"sina-byn/comment-eraser","owner":"sina-byn","description":"comment-eraser is a Node.js package that removes comments from JavaScript files efficiently. It offers customizable options for tailoring the comment removal process and includes an interactive mode for selective file cleanup. Overall, comment-eraser simplifies and streamlines code cleanup tasks.","archived":false,"fork":false,"pushed_at":"2023-07-29T14:20:06.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-08T08:05:04.053Z","etag":null,"topics":["code-cleanup","comment-remover","interactive-mode","javascript","nodejs","npm-package","utility-library"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/sina-byn.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":"2023-07-19T07:36:07.000Z","updated_at":"2023-12-05T09:19:53.000Z","dependencies_parsed_at":"2024-11-05T15:42:44.483Z","dependency_job_id":null,"html_url":"https://github.com/sina-byn/comment-eraser","commit_stats":null,"previous_names":["sina-byn/comment-eraser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sina-byn/comment-eraser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sina-byn%2Fcomment-eraser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sina-byn%2Fcomment-eraser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sina-byn%2Fcomment-eraser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sina-byn%2Fcomment-eraser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sina-byn","download_url":"https://codeload.github.com/sina-byn/comment-eraser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sina-byn%2Fcomment-eraser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272866014,"owners_count":25006310,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["code-cleanup","comment-remover","interactive-mode","javascript","nodejs","npm-package","utility-library"],"created_at":"2024-11-05T15:26:01.273Z","updated_at":"2026-05-09T05:34:52.963Z","avatar_url":"https://github.com/sina-byn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DEPRECATED - comment-eraser [![NPM version](https://img.shields.io/npm/v/comment-eraser.svg?style=flat)](https://www.npmjs.com/package/comment-eraser) [![NPM monthly downloads](https://img.shields.io/npm/dm/comment-eraser.svg?style=flat)](https://npmjs.org/package/comment-eraser) [![NPM total downloads](https://img.shields.io/npm/dt/comment-eraser.svg?style=flat)](https://npmjs.org/package/comment-eraser) \n\n\u003e Removing comments from JavaScript files has never been this easy.\n\nPlease consider following this project's author, [Sina Bayandorian](https://github.com/sina-byn), and consider starring the project to show your :heart: and support.\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n    - [erase](#erase)\n    - [eraseFromString](#erasefromstring)\n- [Configuration](#configuration)\n- [Interactive Mode](#interactive-mode)\n- [Cli Tool](#cli-tool)\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/package/comment-eraser):\n\n```sh\n$ npm install --save comment-eraser\n```\n\n## Usage\n\n```js\nconst { erase } = require('comment-eraser');\n\n// reads eraser.config.json - falls back to DEFAULT_CONFIG if not specified\n// removes comments from specified .js files\nerase();\n```\n\n```js\nconst { eraseFromString } = require('comment-eraser');\n\n// config\nconst config = {\n  type: 'both',\n  code: jsCodeString\n};\n\nconst [commentsRemoved, removedCharsCount, elapsedTime] = eraseFromString(config);\n\nconsole.log(commentsRemoved, removedCharsCount, elapsedTime);\n```\n\n## API\n\n### [erase](index.js#L105)\n\nErases comments from the specified files **-** Read [Configuration](#configuration) and [Interactive Mode](#interactive-mode) for more.\n\n**Params**\n* `configPath`: **String -** optional **-** default is `'eraser.config.json'`\n\n**Returns**\n* `{ filePath, outputPath, commentsRemoved, removedCharsCount, elapsedTime }[] | undefined`: **{ String, String, String, Number, TimeStamp }[ ] | undefined**\n\n**Notes**\n* note that when `interactive` is set to `true` the logs will no longer be available to you and the function will return `undefined`\n\n**Example**\n\n```js\n// note that this function needs no argument to be passed to it\n// since it reads and utilizes eraser.config.json\n\nconst { erase } = require('comment-eraser');\n\nconst logs = erase();\nconsole.log(logs);\n```\n\n### [eraseFromString](index.js#L82)\n\nErases comments from the given `string`.\n\n**Params**\n\n* `code`: **String**\n* `config`: **Object**\n  * `type`: **'both' | 'inline' | 'block'**\n  * `excludePatterns`: **String[ ] -** specifies comment patterns not to be excluded **-** default is `[]`\n  * note that each pattern must be a valid `RegExp` pattern or an error will be thrown \n  * `output`: **{ path: String, file: String, append: Boolean }**\n    * `path`: **String -** default is `''`\n    * `file`: **String -** default is `'output.js'`\n    * `append`: **Boolean -** default is `false`\n\n**Returns**\n\n* `[commentsRemoved, removedCharsCount, outputPath, elapsedTime]`: **[ String, Number, (String | null), TimeStamp ]**\n\n**Notes**\n* if no `output` object is passed then the result won't be written to a file\n* in order to use the default `output` config pass `{}` as the `output`option\n* if two function calls have the same `output` option:\n    * `append` set to `true` **-** all results will be appended to the file\n    * `append` set to `false` **-** only the result of the last function call will be written to the file\n\n**Example**\n\n```js\n// note that in this example no new file is created\n// as no config or output option is passed down to the function\n\nconst { eraseFromString } = require('comment-eraser');\n\nconst sampleString = '// a comment \\n sample js code';\nconst [ commentsRemoved, removedCharsCount, elapsedTime ] = eraseFromString(sampleString);\nconsole.log(commentsRemoved, removedCharsCount, outputPath, elapsedTime);\n```\n\n## Configuration\n\nutilized by the [erase](#erase) function\n\n**eraser.config.json**\n\n* `type`: **'both' | 'inline' | 'block'** specifies the comment type to be erased\n  * `both`: default - all comments\n  * `inline`: inline comments only\n  * `block`: block comments only\n* `include`: **String | String[ ] -** glob pattern **-** js files to be included **-** default is `./**/*`\n* `exclude`: **String[ ] -** glob pattern **-** js files to be excluded **-** default is `[]`\n* `writeToOutput`: **Boolean -** specifies whether to write the output string into specific files **-** default is `true`\n  * based on `replace`, `outputDir`, `postfix`\n* `replace`: **Boolean -** specifies whether to replace the file's content after removing the comments or not  **-** default is `false`\n  * will override `outputDir` and `postfix`if specified\n* `outputDir`: **String -** specifies the directory in which the new files are going the be created **-** default is `no-comments`\n* `postfix`: **String -** specifies the postfix to be added to the new files generated after the comment removal process  **-** default is `-no-comments`\n* `excludePatterns`: **String[ ] -** specifies comment patterns not to be excluded **-** default is `[]`\n  * note that each pattern must be a valid `RegExp` pattern or an error will be thrown\n* `interactive`: **Boolean -** activates interactive mode if set to `true` **-** default is `false`\n\n## Interactive Mode\nIn this mode a temp file named `prelog` is created in which you can specify which files to include or not include one by one and then hit `Enter` to continue the process based on the `prelog` file\n\n* set `interactive` to `true` to activate in `eraser.config.json`\n* only available when using the [erase](#erase) function\n* `=y`: include file **-** default for all files \n* `=n`: exclude file\n* note that the `prelog` file will be removed after the process is finished\n\n**Exmaple - prelog**\n```js\nsample.js=y\nsample-2.js=n\n```\n\n## Cli Tool\n[eraser-cli](https://www.npmjs.com/package/eraser-cli) - the cli tool for this package\neasily integrate the comment-eraser into your build process or install it globally and use it wherever you want","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsina-byn%2Fcomment-eraser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsina-byn%2Fcomment-eraser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsina-byn%2Fcomment-eraser/lists"}