{"id":19574700,"url":"https://github.com/stringparser/utils-debug","last_synced_at":"2025-08-16T13:42:53.831Z","repository":{"id":21536487,"uuid":"24855997","full_name":"stringparser/utils-debug","owner":"stringparser","description":"unobtrusive debug utility","archived":false,"fork":false,"pushed_at":"2017-02-12T11:28:57.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T10:21:50.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stringparser.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-06T17:25:20.000Z","updated_at":"2017-02-12T11:28:58.000Z","dependencies_parsed_at":"2022-08-21T17:01:07.425Z","dependency_job_id":null,"html_url":"https://github.com/stringparser/utils-debug","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Futils-debug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Futils-debug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Futils-debug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Futils-debug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stringparser","download_url":"https://codeload.github.com/stringparser/utils-debug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240840994,"owners_count":19866300,"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-11T06:43:31.129Z","updated_at":"2025-02-26T11:21:06.688Z","avatar_url":"https://github.com/stringparser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# utils-debug [![NPM version][npm-badge]][npm-link][![downloads][downloads-bagde]][npm-link]\n\n[documentation](#documentation) -\n[install](#install) -\n[tests](#tests)\n[todo](#todo) -\n[why](#why)\n\n[![build][build-badge]][build-link]\n\nunobtrusive debug utility\n\n## example\n\n```js\nvar debug = require('utils-debug')();\n\ndebug('hey there');\n\nfn1();\n\nfunction fn1(){\n  debug('%s', 'simple');\n  debug('and easy');\n  debug('debug');\n  fn2();\n}\n\nfunction fn2(){\n  debug('if you need it');\n  fn3();\n}\n\nfunction fn3(){\n  debug('just like...');\n  debug('... you had imagined');\n}\n```\n\nuse **filenames** instead of mnemonics\n\n```\n$ DEBUG=example.js node example.js\nat Object.\u003canonymous\u003e (example.js:5:1)\nhey there\nat fn1 (example.js:10:3)\nsimple\nand easy\ndebug\nat fn2 (example.js:18:3)\nif you need it\nat fn3 (example.js:23:3)\njust like...\n... you had imagined\n```\n\nfilter by **function name**\n\n```\n$ DEBUG=*#fn1#fn2 node example.js\nfn1 (example.js:10:3)\n simple and easy debug\nfn2 (example.js:21:3)\n just like...\n ... you had imagined\n```\n\n## documentation\n\nThe module exports a function factory that takes no arguments.\n\n```js\nvar Debug = require('utils-debug');\n```\n\n_returns_\n - `noop` (empty function) if there was no `process.env.DEBUG`\n - `noop` if the file did not pass the checks given by the flags\n - `debug` function that uses the same format as `console.log`\n\n```js\nvar Debug = require('utils-debug');\nvar debug = Debug();\n\ndebug('hey there'); fn();\n\nfunction fn(){\n  debug('%s', 'simple stuff');\n}\n```\n\n### filters\n\nTo enable `debug` functions that live in your code there are three types of filters.\n\n#### paths separated by comma\n\n```sh\n$ DEBUG=lib/dir/,lib/file1,lib/file2.js node program.js\n```\n\nThe extension is optional. If a path ends with slash (forward or backward) _it will be considered\na directory_.\n\n\u003e NOTE: paths have to be relative to the [CWD](https://en.wikipedia.org/wiki/Working_directory#In_operating_systems)\n\n#### function names starting with a pound sign\n\n```sh\n$ DEBUG=*#method1#method2 node program.js\n```\n\n#### wilcards\n\n - `DEBUG=*` will match any file(s)\n - `DEBUG=folder/*/*` any file one dir deep after `folder`\n - `DEBUG=folder/*/file.js` matches any directory after `folder` 1 folder deep\n - `DEBUG=folder/**` any file after directory `folder` with any folder depth\n - `DEBUG=folder/**/file.js` any file after directory `folder` with any folder depth that ends up on `file.js`\n\n## why\n\nYou want expressive, unobtrusive debugging.\n\n## install\n\nWith [npm][npm-link]\n```sh\n$ npm install utils-debug\n```\n\n## tests\n\nTo run the tests\n```\n  $ npm test\n```\n\noutput\n```\n  filter\n    ✓ resolves filepaths from CWD\n    ✓ files should not need extension\n    ✓ files should be separated by comma\n    ✓ DEBUG=* makes util.filter.star = true\n    ✓ DEBUG=folder/ or would be treated as file\n    ✓ DEBUG=folder/* does not qualify as *\n    ✓ DEBUG=folder/*#method is labeled as fn flag\n    ✓ DEBU=folder/*#method1#method2 to filter more than one\n\n  skipFile\n    ✓ * does not skip any files\n    ✓ folder/file.js skips any other file\n    ✓ folder/*/file.js is wilcard for only one folder deep\n    ✓ folder/*/file.js skips any other files\n    ✓ folder/**/file.js is wilcard for any one folder depth\n    ✓ folder/**/file.js skips any other files\n\n  14 passing (34ms)\n```\n\n## todo\n\n- [ ] aliasing (to use it instead of filename)\n- [ ] glob matching\n\n### license\n\nThe MIT License (MIT)\n\nCopyright (c) 2014-present Javier Carrillo\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[npm-link]: http://www.npmjs.org/package/utils-debug\n[npm-badge]: http://img.shields.io/npm/v/utils-debug.svg?style=flat-square\n\n[build-link]: https://travis-ci.org/stringparser/utils-debug/builds\n[build-badge]: http://img.shields.io/travis/stringparser/utils-debug/master.svg?style=flat-square\n\n[license-link]: http://opensource.org/licenses/MIT\n[license-badge]: http://img.shields.io/npm/l/utils-debug.svg?style=flat-square\n\n[downloads-bagde]: http://img.shields.io/npm/dm/utils-debug.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringparser%2Futils-debug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstringparser%2Futils-debug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringparser%2Futils-debug/lists"}