{"id":29826840,"url":"https://github.com/coderaiser/estrace","last_synced_at":"2025-07-29T05:35:41.116Z","repository":{"id":57230630,"uuid":"377152474","full_name":"coderaiser/estrace","owner":"coderaiser","description":"Trace functions in EcmaScript Modules","archived":false,"fork":false,"pushed_at":"2025-01-29T18:58:40.000Z","size":146,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-14T00:06:27.749Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderaiser.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","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":"2021-06-15T12:19:08.000Z","updated_at":"2025-01-29T18:58:42.000Z","dependencies_parsed_at":"2023-12-13T09:55:35.893Z","dependency_job_id":"2a64c0fa-752c-46f9-9004-61d727067885","html_url":"https://github.com/coderaiser/estrace","commit_stats":{"total_commits":159,"total_committers":2,"mean_commits":79.5,"dds":0.04402515723270439,"last_synced_commit":"5b723fb5a7ebb0911aed2939004352e8faaff6ed"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"purl":"pkg:github/coderaiser/estrace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderaiser","download_url":"https://codeload.github.com/coderaiser/estrace/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festrace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267633699,"owners_count":24118781,"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-07-29T02:00:12.549Z","response_time":2574,"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":[],"created_at":"2025-07-29T05:35:28.678Z","updated_at":"2025-07-29T05:35:41.103Z","avatar_url":"https://github.com/coderaiser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESTrace [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/estrace.svg?style=flat\n[BuildStatusURL]: https://github.com/coderaiser/estrace/actions?query=workflow%3A%22Node+CI%22 \"Build Status\"\n[BuildStatusIMGURL]: https://github.com/coderaiser/estrace/workflows/Node%20CI/badge.svg\n[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[NPMURL]: https://npmjs.org/package/estrace \"npm\"\n[LicenseURL]: https://tldrlegal.com/license/mit-license \"MIT License\"\n[CoverageURL]: https://coveralls.io/github/coderaiser/estrace?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/estrace/badge.svg?branch=master\u0026service=github\n\nTrace functions in Node.js [EcmaScript Modules](https://nodejs.org/api/esm.html#esm_modules_ecmascript_modules). For CommonJS use [njsTrace](https://github.com/ValYouW/njsTrace).\n\n## Install\n\n`npm i estrace`\n\n## Run\n\n[Loaders](https://nodejs.org/api/esm.html#esm_loaders) used to get things done, run with `--loader` flag:\n\n```sh\nNODE_OPTIONS=\"'--loader estrace --no-warnings'\" node lint.js\n```\n\n## Perf\n\nWhen you want to see report of the most hot function calls count use:\n\n```sh\nNODE_OPTIONS=\"'--loader estrace/perf --no-warnings'\" node example/perf.js\n```\n\n## Example\n\nLet's suppose you want to trace `lint.js`:\n\n```js\nconst checkFile = (a) =\u003e a;\nlint();\n\nfunction lint(runners) {\n    const files = getFiles(runners);\n    const checkedFiles = checkFiles(files);\n    \n    return checkedFiles;\n}\n\nfunction getFiles(runners) {\n    const files = [];\n    \n    for (const run of runners) {\n        files.push(...run());\n    }\n    \n    return files;\n}\n\nfunction lintFiles(files) {\n    const linted = [];\n    \n    for (const file of files) {\n        linted.push(checkFile(file));\n    }\n    \n    return linted;\n}\n```\n\nYou will see something like this\n\n```sh\ncoderaiser@cloudcmd:~/estrace$ node --loader estrace example/lint.js\n..💣 lint([]) 16.05mb file:///Users/coderaiser/estrace/example/lint.js:5\n....💣 getFiles([]) 16.05mb file:///Users/coderaiser/estrace/example/lint.js:12\n....💥 getFiles 16.06mb file:///Users/coderaiser/estrace/example/lint.js:12\n....💣 lintFiles([]) 16.06mb file:///Users/coderaiser/estrace/example/lint.js:22\n....💥 lintFiles 16.06mb file:///Users/coderaiser/estrace/example/lint.js:22\n..💥 lint 16.06mb file:///Users/coderaiser/estrace/example/lint.js:5\n```\n\n## How `ESTrace` works?\n\nLet's suppost you have a function: `const fn = (a) =\u003e a`. `EStrace` will replace it with:\n\n```js\nconst fn = (a) =\u003e {\n    try {\n        var __estrace_context = __estrace.enter('\u003canonymous:2\u003e', 'file://hello.js:2', arguments);\n        return a;\n    } finally {\n        __estrace.exit('\u003canonymous:2\u003e', 'file://hello.js:2', __estrace_context);\n    }\n};\n```\n\nAnd you cat get more information about the way your code works.\n\n## Ignore function\n\nWhen you need to ignore a function, just add `__estrace.ignore()` before function:\n\n```js\nexport /* __estrace.ignore() */\nfunction enter() {}\n```\n\nAnd `ESTrace` won't touch it.\n\n## Using as plugin\n\nFirst of all `ESTrace` is plugin for 🐊[**Putout**](https://github.com/coderaiser/putout) and it can be used independely:\n\n```js\nimport putout from 'putout';\nimport {estracePlugin} from 'estrace/plugin';\n\nconst source = `\n    const fn = (a) =\u003e a;\n`;\n\nconst {code} = putout(source, {\n    plugins: [estracePlugin],\n});\n\nconsole.log(code);\n```\n\n### Passing file url\n\nIf you need to pass `url`, you can with help of `rules` :\n\n```js\nconst {code} = putout(source, {\n    rules: {\n        'estrace/trace': ['on', {\n            url: 'file://hello.js',\n        }],\n    },\n    plugins: [estracePlugin],\n});\n```\n\n### Exclude functions\n\nWhen you need to `exclude` some kinds of functions, you can use universal [cross-plugin way](https://github.com/coderaiser/putout#exclude):\n\n```js\nconst {code} = putout(source, {\n    rules: {\n        'estrace/trace': ['on', {\n            url: 'file://hello.js',\n            exclude: [\n                'ArrowFunctionExpression',\n            ],\n        }],\n    },\n    plugins: [estracePlugin],\n});\n```\n\n### Overriding plugin name\n\nIf for some reason you need to override the name of a plugin, you can use default import\nand name it in a way you like.\n\n```js\nimport putout from 'putout';\nimport funnyTracer from 'estrace/plugin';\n\nconst source = `\n    const fn = (a) =\u003e a;\n`;\n\nconst {code} = putout(source, {\n    rules: {\n        'funnyTracer/trace': ['on', {\n            url: 'file://hello.js',\n        }],\n    },\n    plugins: [\n        ['funnyTracer', funnyTracer],\n    ],\n});\n\nconsole.log(code);\n```\n\n#### Supported function types:\n\n— `FunctionDeclaration` (named):\n\n```js\nfunction hello() {\n    return 'world';\n}\n```\n\n— `FunctionExpression` (anonymous):\n\n```js\nhello(function(word) {\n    return `hello ${word}`;\n});\n```\n\n— `ArrowFunctionExpression` (arrow):\n\n```js\nhello((word) =\u003e {\n    return `hello ${word}`;\n});\n```\n\n— `ClassMethod` (method):\n\n```js\nclass Hello {\n    hello(word) {\n        return `hello ${word}`;\n    }\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Festrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderaiser%2Festrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Festrace/lists"}