pax_global_header00006660000000000000000000000064147266300320014515gustar00rootroot0000000000000052 comment=ea4173e88d68d8e9a95717fa5548a3ea524c2dc9 ljharb-safe-regex-test-9360cf0/000077500000000000000000000000001472663003200163145ustar00rootroot00000000000000ljharb-safe-regex-test-9360cf0/.eslintrc000066400000000000000000000001721472663003200201400ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { "new-cap": [2, { "capIsNewExceptions": ["GetIntrinsic"] }], }, } ljharb-safe-regex-test-9360cf0/.github/000077500000000000000000000000001472663003200176545ustar00rootroot00000000000000ljharb-safe-regex-test-9360cf0/.github/FUNDING.yml000066400000000000000000000011121472663003200214640ustar00rootroot00000000000000# These are supported funding model platforms github: [ljharb] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: npm/safe-regex-test community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ljharb-safe-regex-test-9360cf0/.github/workflows/000077500000000000000000000000001472663003200217115ustar00rootroot00000000000000ljharb-safe-regex-test-9360cf0/.github/workflows/node-aught.yml000066400000000000000000000005161472663003200244710ustar00rootroot00000000000000name: 'Tests: node.js < 10' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '< 10' type: minors command: npm run tests-only node: name: 'node < 10' needs: [tests] runs-on: ubuntu-latest steps: - run: 'echo tests completed' ljharb-safe-regex-test-9360cf0/.github/workflows/node-pretest.yml000066400000000000000000000002061472663003200250430ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main ljharb-safe-regex-test-9360cf0/.github/workflows/node-tens.yml000066400000000000000000000005471472663003200243360ustar00rootroot00000000000000name: 'Tests: node.js 10 - 20' on: [pull_request, push] permissions: contents: read jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 10 < 20' type: minors command: npm run tests-only node: name: 'node 10 - 20' needs: [tests] runs-on: ubuntu-latest steps: - run: true ljharb-safe-regex-test-9360cf0/.github/workflows/node-twenties.yml000066400000000000000000000005361472663003200252250ustar00rootroot00000000000000name: 'Tests: node.js >= 20' on: [pull_request, push] permissions: contents: read jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 20' type: minors command: npm run tests-only node: name: 'node >= 20' needs: [tests] runs-on: ubuntu-latest steps: - run: true ljharb-safe-regex-test-9360cf0/.github/workflows/rebase.yml000066400000000000000000000007001472663003200236720ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] permissions: contents: read jobs: _: permissions: contents: write # for ljharb/rebase to push code to rebase pull-requests: read # for ljharb/rebase to get info about PR name: "Automatic Rebase" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: ljharb/rebase@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ljharb-safe-regex-test-9360cf0/.github/workflows/require-allow-edits.yml000066400000000000000000000003031472663003200263260ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main ljharb-safe-regex-test-9360cf0/.gitignore000066400000000000000000000032511472663003200203050ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage *.lcov # nyc test coverage .nyc_output # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # TypeScript v1 declaration files typings/ # TypeScript cache *.tsbuildinfo # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Microbundle cache .rpt2_cache/ .rts2_cache_cjs/ .rts2_cache_es/ .rts2_cache_umd/ # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env .env.test # parcel-bundler cache (https://parceljs.org/) .cache # Next.js build output .next # Nuxt.js build / generate output .nuxt dist # Gatsby files .cache/ # Comment in the public line in if your project uses Gatsby and *not* Next.js # https://nextjs.org/blog/next-9-1#public-directory-support # public # vuepress build output .vuepress/dist # Serverless directories .serverless/ # FuseBox cache .fusebox/ # DynamoDB Local files .dynamodb/ # TernJS port file .tern-port # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock .npmignore ljharb-safe-regex-test-9360cf0/.npmrc000066400000000000000000000000671472663003200174370ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s ljharb-safe-regex-test-9360cf0/.nycrc000066400000000000000000000003301472663003200174270ustar00rootroot00000000000000{ "all": true, "check-coverage": false, "reporter": ["text-summary", "text", "html", "json"], "lines": 86, "statements": 85.93, "functions": 82.43, "branches": 76.06, "exclude": [ "coverage", "test" ] } ljharb-safe-regex-test-9360cf0/CHANGELOG.md000066400000000000000000000102431472663003200201250ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [v1.1.0](https://github.com/ljharb/safe-regex-test/compare/v1.0.3...v1.1.0) - 2024-12-12 ### Commits - [actions] split out node 10-20, and 20+ [`b4a46bb`](https://github.com/ljharb/safe-regex-test/commit/b4a46bb30542251df8051aec52561ce2bb162f85) - [New] add types [`5cb24eb`](https://github.com/ljharb/safe-regex-test/commit/5cb24eb6d074fdae200446e172f1ab485460c34e) - [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `es-value-fixtures`, `object-inspect`, `tape` [`e225ca0`](https://github.com/ljharb/safe-regex-test/commit/e225ca081b77ea105b5e913a00473066efeb471d) - [Refactor] use `call-bound` directly [`9be3cd2`](https://github.com/ljharb/safe-regex-test/commit/9be3cd2f390f23c0075ec93e5abdace0ee5d9d9d) - [Deps] update `call-bind`, `is-regex` [`524b736`](https://github.com/ljharb/safe-regex-test/commit/524b73677e16de9dde27dfb8f30ac4760071bbda) - [Tests] replace `aud` with `npm audit` [`f3cd537`](https://github.com/ljharb/safe-regex-test/commit/f3cd5379e48152daeb51fdd09e15d3ec74797761) - [Dev Deps] add missing peer dep [`14da559`](https://github.com/ljharb/safe-regex-test/commit/14da559a0620b99a262ab9610dba13720915360f) ## [v1.0.3](https://github.com/ljharb/safe-regex-test/compare/v1.0.2...v1.0.3) - 2024-02-06 ### Commits - [Refactor] use `es-errors`, so things that only need those do not need `get-intrinsic` [`d6ba2f9`](https://github.com/ljharb/safe-regex-test/commit/d6ba2f948c679c3104ce6d6c897bedff0f1c5b74) - [Deps] update `call-bind`, `get-intrinsic` [`5a3b1d7`](https://github.com/ljharb/safe-regex-test/commit/5a3b1d755e46f010e6930f15ec30eae023feffd3) - [Dev Deps] update `tape` [`75fb719`](https://github.com/ljharb/safe-regex-test/commit/75fb71937c5daf1326052c59d6f251f439cd9332) ## [v1.0.2](https://github.com/ljharb/safe-regex-test/compare/v1.0.1...v1.0.2) - 2024-01-11 ### Commits - [meta] package.json `sideEffects` should be boolean [`094bb88`](https://github.com/ljharb/safe-regex-test/commit/094bb88d93ce25e26d20f5badee4e45acf0e3ac5) ## [v1.0.1](https://github.com/ljharb/safe-regex-test/compare/v1.0.0...v1.0.1) - 2024-01-09 ### Commits - [Tests] add nyc for coverage [`7e3f525`](https://github.com/ljharb/safe-regex-test/commit/7e3f5254efdf0979f72492f0e7f52a3a9814591f) - [Dev Deps] update `@ljharb/eslint-config`, `aud`, `npmignore`, `object-inspect`, `tape` [`e7e0169`](https://github.com/ljharb/safe-regex-test/commit/e7e016949b78602f24debc1185c26f33cc4e9d1b) - [actions] update rebase action [`2962694`](https://github.com/ljharb/safe-regex-test/commit/2962694bce7ffa278e873911072c11119bb3a608) - [readme] add testing badges; remove david-dm badges [`e9dfd83`](https://github.com/ljharb/safe-regex-test/commit/e9dfd830655ac702ac7b7947f7076bb524994968) - [Dev Deps] update `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`496fe99`](https://github.com/ljharb/safe-regex-test/commit/496fe99aa66f20cadb1cf79f6d479b87ae95b620) - [Deps] update `call-bind`, `get-intrinsic` [`d94c5ba`](https://github.com/ljharb/safe-regex-test/commit/d94c5badd0362df8ff7ced38b50d20550fd629c1) - [meta] add missing `engines.node` [`f3d4711`](https://github.com/ljharb/safe-regex-test/commit/f3d4711a51b21330e34f5f27e45452fbdb924715) - [Deps] update `get-intrinsic` [`0eeedd7`](https://github.com/ljharb/safe-regex-test/commit/0eeedd74d0313fab9b0718895c02905f702ecb4d) - [meta] add `sideEffects` flag [`fe1655f`](https://github.com/ljharb/safe-regex-test/commit/fe1655f16449208d987d9f4b7dafb15564ca80f7) ## v1.0.0 - 2022-09-22 ### Commits - Initial implementation, tests, readme [`0273e9f`](https://github.com/ljharb/safe-regex-test/commit/0273e9f96f4b09df413523f4faacc8ae9ac5e6cb) - Initial commit [`b6c1edf`](https://github.com/ljharb/safe-regex-test/commit/b6c1edf740e6105fb71c34c1c69fadd837e8f7ab) - npm init [`c7f5765`](https://github.com/ljharb/safe-regex-test/commit/c7f576580607b16458b5a16e6bfa3b639e49c6bd) - Only apps should have lockfiles [`1162bf0`](https://github.com/ljharb/safe-regex-test/commit/1162bf011835040f7e2c9936734294b2d98536bf) ljharb-safe-regex-test-9360cf0/LICENSE000066400000000000000000000020571472663003200173250ustar00rootroot00000000000000MIT License Copyright (c) 2022 Jordan Harband Permission 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE 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. ljharb-safe-regex-test-9360cf0/README.md000066400000000000000000000034441472663003200176000ustar00rootroot00000000000000# safe-regex-test [![Version Badge][npm-version-svg]][package-url] [![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][npm-badge-png]][package-url] Give a regex, get a robust predicate function that tests it against a string. This will work even if `RegExp.prototype` is altered later. ## Getting started ```sh npm install --save safe-regex-test ``` ## Usage/Examples ```js var regexTester = require('safe-regex-test'); var assert = require('assert'); var tester = regexTester('a'); assert.ok(tester('a')); assert.notOk(tester('b')); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/safe-regex-test [npm-version-svg]: https://versionbadg.es/ljharb/safe-regex-test.svg [deps-svg]: https://david-dm.org/ljharb/safe-regex-test.svg [deps-url]: https://david-dm.org/ljharb/safe-regex-test [dev-deps-svg]: https://david-dm.org/ljharb/safe-regex-test/dev-status.svg [dev-deps-url]: https://david-dm.org/ljharb/safe-regex-test#info=devDependencies [npm-badge-png]: https://nodei.co/npm/safe-regex-test.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/safe-regex-test.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/safe-regex-test.svg [downloads-url]: https://npm-stat.com/charts.html?package=safe-regex-test [codecov-image]: https://codecov.io/gh/ljharb/safe-regex-test/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/ljharb/safe-regex-test/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/safe-regex-test [actions-url]: https://github.com/ljharb/safe-regex-test/actions ljharb-safe-regex-test-9360cf0/index.d.ts000066400000000000000000000001401472663003200202100ustar00rootroot00000000000000declare function regexTester(regex: RegExp): (string: string) => boolean; export = regexTester;ljharb-safe-regex-test-9360cf0/index.js000066400000000000000000000006251472663003200177640ustar00rootroot00000000000000'use strict'; var callBound = require('call-bound'); var isRegex = require('is-regex'); var $exec = callBound('RegExp.prototype.exec'); var $TypeError = require('es-errors/type'); /** @type {import('.')} */ module.exports = function regexTester(regex) { if (!isRegex(regex)) { throw new $TypeError('`regex` must be a RegExp'); } return function test(s) { return $exec(regex, s) !== null; }; }; ljharb-safe-regex-test-9360cf0/package.json000066400000000000000000000043501472663003200206040ustar00rootroot00000000000000{ "name": "safe-regex-test", "version": "1.1.0", "description": "Give a regex, get a robust predicate function that tests it against a string.", "main": "index.js", "exports": { ".": "./index.js", "./package.json": "./package.json" }, "sideEffects": false, "scripts": { "prepack": "npmignore --auto --commentLines=autogenerated", "version": "auto-changelog && git add CHANGELOG.md", "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"", "lint": "eslint --ext=js,mjs .", "postlint": "tsc && attw -P", "prepublish": "not-in-publish || npm run prepublishOnly", "prepublishOnly": "safe-publish-latest", "pretest": "npm run lint", "tests-only": "nyc tape test", "test": "npm run tests-only", "posttest": "npx npm@'>= 10.2' audit --production" }, "repository": { "type": "git", "url": "git+https://github.com/ljharb/safe-regex-test.git" }, "keywords": [ "regex", "regexp", "test", "tester", "safe", "robust", "exec" ], "author": "Jordan Harband ", "funding": { "url": "https://github.com/sponsors/ljharb" }, "license": "MIT", "bugs": { "url": "https://github.com/ljharb/safe-regex-test/issues" }, "homepage": "https://github.com/ljharb/safe-regex-test#readme", "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "is-regex": "^1.2.1" }, "devDependencies": { "@arethetypeswrong/cli": "^0.17.1", "@ljharb/eslint-config": "^21.1.1", "@ljharb/tsconfig": "^0.2.2", "@types/for-each": "^0.3.3", "@types/object-inspect": "^1.13.0", "@types/tape": "^5.6.5", "auto-changelog": "^2.5.0", "encoding": "^0.1.13", "es-value-fixtures": "^1.5.0", "eslint": "=8.8.0", "for-each": "^0.3.3", "in-publish": "^2.0.1", "npmignore": "^0.3.1", "nyc": "^10.3.2", "object-inspect": "^1.13.3", "safe-publish-latest": "^2.0.0", "tape": "^5.9.0", "typescript": "next" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true }, "publishConfig": { "ignore": [ ".github/workflows" ] }, "engines": { "node": ">= 0.4" } } ljharb-safe-regex-test-9360cf0/test/000077500000000000000000000000001472663003200172735ustar00rootroot00000000000000ljharb-safe-regex-test-9360cf0/test/index.js000066400000000000000000000016501472663003200207420ustar00rootroot00000000000000'use strict'; var test = require('tape'); var v = require('es-value-fixtures'); var forEach = require('for-each'); var inspect = require('object-inspect'); var regexTester = require('../'); test('regex tester', function (t) { t.equal(typeof regexTester, 'function', 'is a function'); t.test('non-regexes', function (st) { forEach([].concat( // @ts-expect-error TS sucks with concat v.primitives, v.objects ), function (val) { st['throws']( function () { regexTester(val); }, TypeError, inspect(val) + ' is not a regex' ); }); st.end(); }); t.test('regexes', function (st) { var tester = regexTester(/a/); st.equal(typeof tester, 'function', 'returns a function'); st.equal(tester('a'), true, 'returns true for a match'); st.equal(tester('b'), false, 'returns false for a non-match'); st.equal(tester('a'), true, 'returns true for a match again'); st.end(); }); t.end(); }); ljharb-safe-regex-test-9360cf0/tsconfig.json000066400000000000000000000001661472663003200210260ustar00rootroot00000000000000{ "extends": "@ljharb/tsconfig", "compilerOptions": { // "target": "es2021", }, "exclude": [ "coverage", ], }