{"id":28881080,"url":"https://github.com/opensly/is-true-regex","last_synced_at":"2026-01-20T16:38:56.061Z","repository":{"id":261891183,"uuid":"885647880","full_name":"opensly/is-true-regex","owner":"opensly","description":"Determines if a given value is a regular expression.","archived":false,"fork":false,"pushed_at":"2025-06-15T06:01:22.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-15T06:49:57.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/opensly.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://www.paypal.com/paypalme/LakshmikanthV"]}},"created_at":"2024-11-09T02:58:32.000Z","updated_at":"2025-06-15T06:07:37.000Z","dependencies_parsed_at":"2024-11-09T03:31:09.718Z","dependency_job_id":"e4aba974-94b1-4030-a400-7615dd7c74a8","html_url":"https://github.com/opensly/is-true-regex","commit_stats":null,"previous_names":["opensly/isregex","opensly/is-true-regex"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/opensly/is-true-regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensly%2Fis-true-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensly%2Fis-true-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensly%2Fis-true-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensly%2Fis-true-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opensly","download_url":"https://codeload.github.com/opensly/is-true-regex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensly%2Fis-true-regex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261003183,"owners_count":23095677,"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":"2025-06-20T19:07:13.730Z","updated_at":"2026-01-20T16:38:56.045Z","avatar_url":"https://github.com/opensly.png","language":"TypeScript","funding_links":["https://www.paypal.com/paypalme/LakshmikanthV"],"categories":[],"sub_categories":[],"readme":"# is-true-regex\n\n[![npm version](https://img.shields.io/npm/v/is-true-regex.svg)](https://www.npmjs.com/package/is-true-regex)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)\n\nA robust utility to check if a value is a RegExp object. Works with both JavaScript and TypeScript, supports cross-realm/iframe scenarios, and handles edge cases securely.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [JavaScript](#javascript)\n  - [TypeScript](#typescript)\n- [API](#api)\n- [Security](#security)\n- [Performance](#performance)\n- [License](#license)\n\n## Features\n\n- ✅ TypeScript support with type guards\n- ✅ Cross-realm/iframe compatibility\n- ✅ Secure against spoofing attempts\n- ✅ Handles edge cases and error conditions\n- ✅ Zero dependencies\n- ✅ High performance with early returns\n\n## Installation\n\n```bash\nnpm install is-true-regex\n```\n\n## Usage\n\n### JavaScript\n```javascript\nimport isTrueRegex from \"is-true-regex\";\n\n// Basic usage\nisTrueRegex(/abc/); // true\nisTrueRegex(new RegExp('abc')); // true\nisTrueRegex('abc'); // false\nisTrueRegex(null); // false\nisTrueRegex(undefined); // false\n\n// Edge cases\nisTrueRegex({}); // false\nisTrueRegex([]); // false\nisTrueRegex(function() {}); // false\nisTrueRegex(new Date()); // false\n```\n\n### TypeScript\n```typescript\nimport isTrueRegex from \"is-true-regex\";\n\n// Type guard usage\nconst value: unknown = /abc/;\nif (isTrueRegex(value)) {\n    // value is now typed as RegExp\n    value.test('abc'); // TypeScript knows this is safe\n}\n\n// Basic usage\nisTrueRegex(/abc/); // true\nisTrueRegex(new RegExp('abc')); // true\nisTrueRegex('abc'); // false\n```\n\n## API\n\n### `isTrueRegex(value: unknown): value is RegExp`\n\nChecks if the provided value is a RegExp object. The function is designed to be secure and reliable, handling various edge cases:\n\n- Cross-realm/iframe scenarios\n- Objects with manipulated `Symbol.toStringTag`\n- Proxy objects\n- Frozen and sealed objects\n- Objects with getters that throw\n- Objects with circular references\n- Subclassed RegExp objects\n\n#### Parameters\n\n- `value` (`unknown`): The value to check\n\n#### Returns\n\n- `boolean`: `true` if the value is a RegExp object, `false` otherwise\n\n## Security\n\nThe implementation is designed to be secure against common spoofing attempts:\n- Rejects objects that only mimic RegExp properties\n- Validates prototype chain integrity\n- Handles Symbol.toStringTag manipulation\n- Safely handles error conditions\n\n## Performance\n\nThe implementation is optimized for performance:\n- Early returns for null/undefined values\n- Early returns for primitive types\n- Efficient prototype chain traversal\n- No unnecessary property checks\n\n## License\n\nMIT \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopensly%2Fis-true-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopensly%2Fis-true-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopensly%2Fis-true-regex/lists"}