{
  "_id": "graphmatch",
  "maintainers": [
    {
      "name": "fabiospampinato",
      "email": "spampinabio@gmail.com"
    }
  ],
  "keywords": [
    "regex",
    "regexp",
    "dag",
    "graph",
    "match"
  ],
  "dist-tags": {
    "latest": "1.1.1"
  },
  "_rev": "5-d5ed5fca128c3abc08546981ceb2c96d",
  "description": "A low-level utility for matching a string against a directed acyclic graph of regexes.",
  "readme": "# Graphmatch\n\nA low-level utility for matching a string against a directed acyclic graph of regexes.\n\n- It supports matching strings partially too.\n- It supports fine-grained control over which nodes in the graph can be matched partially or not.\n- It supports compiling the whole graph to a regex, even for partial matches.\n- The graph will always be matched against the input string from the very start.\n- RegExp flags are supported as long as they are the same for all the regexes in the graph.\n\n## Install\n\n```sh\nnpm install graphmatch\n```\n\n## Usage\n\n```ts\nimport graphmatch from 'graphmatch';\n\n// Let's say we would like to match against this glob: foo/{bar,baz}/qux\n// Let's express that as a graph of regexes that this library can match against\n// Whether you reuse the \"qux\" node or not doesn't matter, both are supported\n\nconst GRAPH = {\n  regex: /foo/,\n  children: [\n    {\n      regex: /\\//,\n      children: [\n        {\n          regex: /bar/,\n          children: [\n            {\n              regex: /\\//,\n              children: [\n                {\n                  regex: /qux/\n                }\n              ]\n            }\n          ]\n        },\n        {\n          regex: /baz/,\n          children: [\n            {\n              regex: /\\//,\n              children: [\n                {\n                  regex: /qux/\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    }\n  ]\n};\n\n// Let's now match against the graph, fully\n\ngraphmatch ( GRAPH, 'foo/bar/qux' ); // => true\ngraphmatch ( GRAPH, 'foo/baz/qux' ); // => true\n\ngraphmatch ( GRAPH, 'foo/bar/whoops' ); // => false\ngraphmatch ( GRAPH, 'foo/baz' ); // => false\n\n// Let's now match against the graph, partially\n// A partial match happens when any node in the graph sees the end of the string, either before or after the node's regex is executed\n\ngraphmatch ( GRAPH, 'foo/bar/qux', { partial: true } ); // => true\ngraphmatch ( GRAPH, 'foo/bar/', { partial: true } ); // => true\ngraphmatch ( GRAPH, 'foo/bar', { partial: true } ); // => true\ngraphmatch ( GRAPH, 'foo/', { partial: true } ); // => true\ngraphmatch ( GRAPH, 'foo', { partial: true } ); // => true\n\ngraphmatch ( GRAPH, 'foo/bar/whoops', { partial: true } ); // => false\ngraphmatch ( GRAPH, 'foo/barsomething', { partial: true } ); // => false\ngraphmatch ( GRAPH, 'bar', { partial: true } ); // => false\n\n// As we just saw partial matching is set to \"false\" by default, and there is an option to set it to \"true\" by default\n// But you can also decide on a node-by-node basis whether partial matching should be enabled or disabled for that particular node\n// A partial node will match if the whole input string has been consumed, right before or after the node's regex is executed\n// This has higher priority compared to the global setting\n// This is useful for fine-grained control over which nodes can be matched partially\n\nconst NODE_NEVER_PARTIAL = { // This node will never match partially\n  partial: false,\n  regex: /foo/,\n  children: [],\n};\n\nconst NODE_ALWAYS_PARTIAL = { // This node will always match partially\n  partial: true,\n  regex: /foo/,\n  children: [],\n};\n\n// Let's now compile the whole graph to a single regex\n// This is useful if you expect to match against the graph multiple times\n// It's faster to compile the graph once and match against it multiple times\n\nconst fullRe = graphmatch.compile ( GRAPH ); // => RegExp\n\nfullRe.test ( 'foo/bar/qux' ); // => true\nfullRe.test ( 'foo/bar' ); // => false\n\nconst partialRe = graphmatch.compile ( GRAPH, { partial: true } ); // => RegExp\n\npartialRe.test ( 'foo/bar/qux' ); // => true\npartialRe.test ( 'foo/bar' ); // => true\n```\n\n## License\n\nMIT © Fabio Spampinato\n",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/fabiospampinato/graphmatch.git"
  },
  "bugs": {
    "url": "https://github.com/fabiospampinato/graphmatch/issues"
  },
  "license": "MIT",
  "versions": {
    "1.0.0": {
      "name": "graphmatch",
      "version": "1.0.0",
      "keywords": [
        "regex",
        "regexp",
        "dag",
        "graph",
        "match"
      ],
      "_id": "graphmatch@1.0.0",
      "maintainers": [
        {
          "name": "fabiospampinato",
          "email": "spampinabio@gmail.com"
        }
      ],
      "homepage": "https://github.com/fabiospampinato/graphmatch#readme",
      "bugs": {
        "url": "https://github.com/fabiospampinato/graphmatch/issues"
      },
      "dist": {
        "shasum": "4444649192253e1a0f563132e3a812460c48521b",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/graphmatch/-/graphmatch-1.0.0.tgz",
        "fileCount": 10,
        "integrity": "sha512-k/8DQYp7atBb3WsAErBMUEcALBxq6Lvhl1eg9VuwlxpWq22EpbgcL9vxcJrDt+bv10FMHQR2Ew0hsDJ/iPWaUw==",
        "signatures": [
          {
            "sig": "MEQCIHcZN32jSg8CdL8a2A/tm3bGNo5Mw+AA3x+ZHloVjZfjAiB+vsHAv6VDa1Y30MKJq9DO8uGwGByLI4/FHyeldW5N+A==",
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
          }
        ],
        "unpackedSize": 9603
      },
      "main": "dist/index.js",
      "type": "module",
      "types": "./dist/index.d.ts",
      "exports": "./dist/index.js",
      "gitHead": "c033a3fbf24ecc7653f897bb6ffb123c331a5a7a",
      "scripts": {
        "test": "tsex test",
        "clean": "tsex clean",
        "compile": "tsex compile",
        "benchmark": "tsex benchmark",
        "test:watch": "tsex test --watch",
        "compile:watch": "tsex compile --watch",
        "prepublishOnly": "tsex prepare",
        "benchmark:watch": "tsex benchmark --watch"
      },
      "_npmUser": {
        "name": "fabiospampinato",
        "email": "spampinabio@gmail.com"
      },
      "repository": {
        "url": "git+https://github.com/fabiospampinato/graphmatch.git",
        "type": "git"
      },
      "_npmVersion": "10.2.3",
      "description": "A low-level utility for matching a string against a directed acyclic graph of regexes.",
      "directories": {},
      "_nodeVersion": "18.19.0",
      "dependencies": {
        "lodash": "^4.17.21"
      },
      "_hasShrinkwrap": false,
      "devDependencies": {
        "fava": "^0.3.5",
        "tsex": "^4.0.2",
        "benchloop": "^2.1.1",
        "typescript": "^5.9.3"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/graphmatch_1.0.0_1760210437987_0.7172062144756117",
        "host": "s3://npm-registry-packages-npm-production"
      }
    },
    "1.0.1": {
      "name": "graphmatch",
      "version": "1.0.1",
      "keywords": [
        "regex",
        "regexp",
        "dag",
        "graph",
        "match"
      ],
      "_id": "graphmatch@1.0.1",
      "maintainers": [
        {
          "name": "fabiospampinato",
          "email": "spampinabio@gmail.com"
        }
      ],
      "homepage": "https://github.com/fabiospampinato/graphmatch#readme",
      "bugs": {
        "url": "https://github.com/fabiospampinato/graphmatch/issues"
      },
      "dist": {
        "shasum": "5139a89b75c7b345eba5798444960c0c1ce15b80",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/graphmatch/-/graphmatch-1.0.1.tgz",
        "fileCount": 10,
        "integrity": "sha512-PK++Ebrk4O/w6OUpAUA/mmRcXuXCtIjRlsNBIJE8+XM+5mfr0UctGAD741tuJpY2crjHFku86oudi1o9YYo/FQ==",
        "signatures": [
          {
            "sig": "MEUCIQC3T0dPzg8wFcmL11LHR0BKE8VqwAU1T2hJBzIDWR35kAIgceP674N8H6X7dtQO+ztCf98VXBqcyS7S/3SFjSznvzI=",
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
          }
        ],
        "unpackedSize": 9553
      },
      "main": "dist/index.js",
      "type": "module",
      "types": "./dist/index.d.ts",
      "exports": "./dist/index.js",
      "gitHead": "2cd0489382332d02f08d85e5c3000c562317966a",
      "scripts": {
        "test": "tsex test",
        "clean": "tsex clean",
        "compile": "tsex compile",
        "benchmark": "tsex benchmark",
        "test:watch": "tsex test --watch",
        "compile:watch": "tsex compile --watch",
        "prepublishOnly": "tsex prepare",
        "benchmark:watch": "tsex benchmark --watch"
      },
      "_npmUser": {
        "name": "fabiospampinato",
        "email": "spampinabio@gmail.com"
      },
      "repository": {
        "url": "git+https://github.com/fabiospampinato/graphmatch.git",
        "type": "git"
      },
      "_npmVersion": "10.2.3",
      "description": "A low-level utility for matching a string against a directed acyclic graph of regexes.",
      "directories": {},
      "_nodeVersion": "18.19.0",
      "_hasShrinkwrap": false,
      "devDependencies": {
        "fava": "^0.3.5",
        "tsex": "^4.0.2",
        "benchloop": "^2.1.1",
        "typescript": "^5.9.3"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/graphmatch_1.0.1_1760210469331_0.5671029865726829",
        "host": "s3://npm-registry-packages-npm-production"
      }
    },
    "1.0.2": {
      "name": "graphmatch",
      "version": "1.0.2",
      "keywords": [
        "regex",
        "regexp",
        "dag",
        "graph",
        "match"
      ],
      "_id": "graphmatch@1.0.2",
      "maintainers": [
        {
          "name": "fabiospampinato",
          "email": "spampinabio@gmail.com"
        }
      ],
      "homepage": "https://github.com/fabiospampinato/graphmatch#readme",
      "bugs": {
        "url": "https://github.com/fabiospampinato/graphmatch/issues"
      },
      "dist": {
        "shasum": "b0a4c80ec14057290509e083190dad9a747876db",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/graphmatch/-/graphmatch-1.0.2.tgz",
        "fileCount": 9,
        "integrity": "sha512-QcqjrGYos1NAMjFFsBvpWtZk11H8pAOWy5bFafwcTNo/fiiTvN6WzKfGpWyE8DZaZcxQaf28XC4ksLO4WJqCdA==",
        "signatures": [
          {
            "sig": "MEYCIQCTrHo4NMVQuaJ4LquSkstOX/TnN1i1zVfrYwjxDIdRuQIhAP6sG3ebY4E8q/toBHNcqrJizdY6UP7TolLH8+M633z7",
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
          }
        ],
        "unpackedSize": 8142
      },
      "main": "dist/index.js",
      "type": "module",
      "types": "./dist/index.d.ts",
      "exports": "./dist/index.js",
      "gitHead": "4f7cbc20cdcc0f55d81b973f2ccc9132a1267bd0",
      "scripts": {
        "test": "tsex test",
        "clean": "tsex clean",
        "compile": "tsex compile",
        "benchmark": "tsex benchmark",
        "test:watch": "tsex test --watch",
        "compile:watch": "tsex compile --watch",
        "prepublishOnly": "tsex prepare",
        "benchmark:watch": "tsex benchmark --watch"
      },
      "_npmUser": {
        "name": "fabiospampinato",
        "email": "spampinabio@gmail.com"
      },
      "repository": {
        "url": "git+https://github.com/fabiospampinato/graphmatch.git",
        "type": "git"
      },
      "_npmVersion": "10.2.3",
      "description": "A low-level utility for matching a string against a directed acyclic graph of regexes.",
      "directories": {},
      "_nodeVersion": "18.19.0",
      "_hasShrinkwrap": false,
      "devDependencies": {
        "fava": "^0.3.5",
        "tsex": "^4.0.2",
        "benchloop": "^2.1.1",
        "typescript": "^5.9.3"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/graphmatch_1.0.2_1760876999217_0.6179548192822302",
        "host": "s3://npm-registry-packages-npm-production"
      }
    },
    "1.1.0": {
      "name": "graphmatch",
      "version": "1.1.0",
      "keywords": [
        "regex",
        "regexp",
        "dag",
        "graph",
        "match"
      ],
      "_id": "graphmatch@1.1.0",
      "maintainers": [
        {
          "name": "fabiospampinato",
          "email": "spampinabio@gmail.com"
        }
      ],
      "homepage": "https://github.com/fabiospampinato/graphmatch#readme",
      "bugs": {
        "url": "https://github.com/fabiospampinato/graphmatch/issues"
      },
      "dist": {
        "shasum": "1a943a42a4f2c8290d56fba22247483dda4fb3c9",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/graphmatch/-/graphmatch-1.1.0.tgz",
        "fileCount": 9,
        "integrity": "sha512-0E62MaTW5rPZVRLyIJZG/YejmdA/Xr1QydHEw3Vt+qOKkMIOE8WDLc9ZX2bmAjtJFZcId4lEdrdmASsEy7D1QA==",
        "signatures": [
          {
            "sig": "MEUCIQClMRRl9+pX5QSwanRnZYeUXCoLY72/LblHv1R2sMO2PAIgVhau8bxG2USXJUW3afZcpHLmvR2Li39X9KANGeLXmdg=",
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
          }
        ],
        "unpackedSize": 9312
      },
      "main": "dist/index.js",
      "type": "module",
      "types": "./dist/index.d.ts",
      "exports": "./dist/index.js",
      "gitHead": "0b88304dd91cf9d058fb0743fe0ccd41d637a006",
      "scripts": {
        "test": "tsex test",
        "clean": "tsex clean",
        "compile": "tsex compile",
        "benchmark": "tsex benchmark",
        "test:watch": "tsex test --watch",
        "compile:watch": "tsex compile --watch",
        "prepublishOnly": "tsex prepare",
        "benchmark:watch": "tsex benchmark --watch"
      },
      "_npmUser": {
        "name": "fabiospampinato",
        "email": "spampinabio@gmail.com"
      },
      "repository": {
        "url": "git+https://github.com/fabiospampinato/graphmatch.git",
        "type": "git"
      },
      "_npmVersion": "10.2.3",
      "description": "A low-level utility for matching a string against a directed acyclic graph of regexes.",
      "directories": {},
      "_nodeVersion": "18.19.0",
      "_hasShrinkwrap": false,
      "devDependencies": {
        "fava": "^0.3.5",
        "tsex": "^4.0.2",
        "benchloop": "^2.1.1",
        "typescript": "^5.9.3"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/graphmatch_1.1.0_1760898190267_0.47794095502990874",
        "host": "s3://npm-registry-packages-npm-production"
      }
    },
    "1.1.1": {
      "name": "graphmatch",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/fabiospampinato/graphmatch.git"
      },
      "description": "A low-level utility for matching a string against a directed acyclic graph of regexes.",
      "license": "MIT",
      "version": "1.1.1",
      "type": "module",
      "main": "dist/index.js",
      "exports": "./dist/index.js",
      "types": "./dist/index.d.ts",
      "scripts": {
        "benchmark": "tsex benchmark",
        "benchmark:watch": "tsex benchmark --watch",
        "clean": "tsex clean",
        "compile": "tsex compile",
        "compile:watch": "tsex compile --watch",
        "test": "tsex test",
        "test:watch": "tsex test --watch",
        "prepublishOnly": "tsex prepare"
      },
      "keywords": [
        "regex",
        "regexp",
        "dag",
        "graph",
        "match"
      ],
      "devDependencies": {
        "benchloop": "^2.1.1",
        "fava": "^0.3.5",
        "tsex": "^4.0.2",
        "typescript": "^5.9.3"
      },
      "_id": "graphmatch@1.1.1",
      "gitHead": "52d30409dc885d88042954184090629b314e6c88",
      "bugs": {
        "url": "https://github.com/fabiospampinato/graphmatch/issues"
      },
      "homepage": "https://github.com/fabiospampinato/graphmatch#readme",
      "_nodeVersion": "18.19.0",
      "_npmVersion": "10.2.3",
      "dist": {
        "integrity": "sha512-5ykVn/EXM1hF0XCaWh05VbYvEiOL2lY1kBxZtaYsyvjp7cmWOU1XsAdfQBwClraEofXDT197lFbXOEVMHpvQOg==",
        "shasum": "dcec68e8cb74de0a372d5252fc06e241daf71c38",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/graphmatch/-/graphmatch-1.1.1.tgz",
        "fileCount": 9,
        "unpackedSize": 9332,
        "signatures": [
          {
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
            "sig": "MEUCICmLNwkOQVlUWfCCi7roN3lYg/868s+FO0oih8b8He7NAiEA/KGBHfrMyve/Xd2ir9R/VLtRRM7zyQYHcymgmZ9MQ7s="
          }
        ]
      },
      "_npmUser": {
        "name": "fabiospampinato",
        "email": "spampinabio@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "fabiospampinato",
          "email": "spampinabio@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages-npm-production",
        "tmp": "tmp/graphmatch_1.1.1_1771084746393_0.8101614846650373"
      },
      "_hasShrinkwrap": false
    }
  },
  "name": "graphmatch",
  "time": {
    "created": "2025-10-11T19:20:37.986Z",
    "modified": "2026-05-10T17:33:10.546Z",
    "1.0.0": "2025-10-11T19:20:38.165Z",
    "1.0.1": "2025-10-11T19:21:09.563Z",
    "1.0.2": "2025-10-19T12:29:59.412Z",
    "1.1.0": "2025-10-19T18:23:10.448Z",
    "1.1.1": "2026-02-14T15:59:06.563Z"
  },
  "readmeFilename": "readme.md",
  "homepage": "https://github.com/fabiospampinato/graphmatch#readme"
}