{"id":13474867,"url":"https://github.com/sindresorhus/filter-console","last_synced_at":"2025-04-04T07:07:22.402Z","repository":{"id":55415195,"uuid":"152385634","full_name":"sindresorhus/filter-console","owner":"sindresorhus","description":"Filter out unwanted `console.log()` output","archived":false,"fork":false,"pushed_at":"2022-07-08T11:26:58.000Z","size":9,"stargazers_count":247,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T01:24:34.949Z","etag":null,"topics":["browser","console","console-log","devtools","exclude","filter","nodejs","npm-package"],"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/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2018-10-10T08:03:36.000Z","updated_at":"2025-01-07T20:11:36.000Z","dependencies_parsed_at":"2022-08-14T23:50:38.491Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/filter-console","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffilter-console","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffilter-console/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffilter-console/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffilter-console/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/filter-console/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246812379,"owners_count":20837953,"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":["browser","console","console-log","devtools","exclude","filter","nodejs","npm-package"],"created_at":"2024-07-31T16:01:15.538Z","updated_at":"2025-04-04T07:07:22.385Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript"],"sub_categories":[],"readme":"# filter-console\n\n\u003e Filter out unwanted `console.log()` output\n\nCan be useful when you don't control the output, for example, filtering out PropType warnings from a third-party React component.\n\n## Install\n\n```\n$ npm install filter-console\n```\n\n## Usage\n\n```js\nimport filterConsole from 'filter-console';\n\nconst disableFilter = filterConsole(['🐼']);\n\nconst log = () =\u003e {\n\tconsole.log('');\n\tconsole.log('🦄');\n\tconsole.log('🐼');\n\tconsole.log('🐶');\n};\n\nlog();\n\ndisableFilter();\n\nlog();\n```\n\n```\n$ node example.js\n\n🦄\n🐶\n\n🦄\n🐼\n🐶\n```\n\n## API\n\n### filterConsole(excludePatterns, options?)\n\nReturns a function, which when called, disables the filter.\n\n#### excludePatterns\n\nType: `Array\u003cstring | RegExp | Function\u003e`\n\nConsole output that matches any of the given patterns are filtered from being logged. The patterns are matched against what would be logged and not the `console` method input arguments directly. Meaning an exclude pattern of `'foo bar'` will match `console.log('foo %s', 'bar')`.\n\nFilter types:\n- `string`: Checks if the string pattern is included in the console output.\n- `RegExp`: Checks if the RegExp pattern matches the console output.\n- `Function`: Receives the console output as a string and is expected to return a truthy/falsy value of whether to exclude it.\n\n#### options\n\nType: `object`\n\n##### methods\n\nType: `string[]`\\\nDefault: `['log', 'debug', 'info', 'warn', 'error']`\n\nConsole methods to filter.\n\n##### console\n\nType: `object`\\\nDefault: `console`\n\nUse a custom `console` object. Can be useful for testing or mocking.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ffilter-console","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Ffilter-console","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ffilter-console/lists"}