pax_global_header00006660000000000000000000000064146251157250014522gustar00rootroot0000000000000052 comment=7236c907db21470283b413dc52a3a9106d038ff0 node-re2-1.20.12/000077500000000000000000000000001462511572500133005ustar00rootroot00000000000000node-re2-1.20.12/.editorconfig000066400000000000000000000003061462511572500157540ustar00rootroot00000000000000root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_style = space indent_size = 2 [*.{h,cc,cpp}] indent_style = tab indent_size = 4 node-re2-1.20.12/.github/000077500000000000000000000000001462511572500146405ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/000077500000000000000000000000001462511572500163005ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-alpine-node-18/000077500000000000000000000000001462511572500220565ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-alpine-node-18/Dockerfile000066400000000000000000000002201462511572500240420ustar00rootroot00000000000000FROM node:18-alpine RUN apk add --no-cache python3 make gcc g++ linux-headers COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-alpine-node-18/action.yml000066400000000000000000000003411462511572500240540ustar00rootroot00000000000000name: 'Create a binary artifact for Node 18 on Alpine Linux' description: 'Create a binary artifact for Node 18 on Alpine Linux using musl' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-alpine-node-18/entrypoint.sh000077500000000000000000000002301462511572500246230ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-alpine-node-20/000077500000000000000000000000001462511572500220475ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-alpine-node-20/Dockerfile000066400000000000000000000002201462511572500240330ustar00rootroot00000000000000FROM node:20-alpine RUN apk add --no-cache python3 make gcc g++ linux-headers COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-alpine-node-20/action.yml000066400000000000000000000003411462511572500240450ustar00rootroot00000000000000name: 'Create a binary artifact for Node 20 on Alpine Linux' description: 'Create a binary artifact for Node 20 on Alpine Linux using musl' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-alpine-node-20/entrypoint.sh000077500000000000000000000002301462511572500246140ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-alpine-node-21/000077500000000000000000000000001462511572500220505ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-alpine-node-21/Dockerfile000066400000000000000000000002201462511572500240340ustar00rootroot00000000000000FROM node:21-alpine RUN apk add --no-cache python3 make gcc g++ linux-headers COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-alpine-node-21/action.yml000066400000000000000000000003411462511572500240460ustar00rootroot00000000000000name: 'Create a binary artifact for Node 21 on Alpine Linux' description: 'Create a binary artifact for Node 21 on Alpine Linux using musl' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-alpine-node-21/entrypoint.sh000077500000000000000000000002301462511572500246150ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-alpine-node-22/000077500000000000000000000000001462511572500220515ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-alpine-node-22/Dockerfile000066400000000000000000000002201462511572500240350ustar00rootroot00000000000000FROM node:22-alpine RUN apk add --no-cache python3 make gcc g++ linux-headers COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-alpine-node-22/action.yml000066400000000000000000000003411462511572500240470ustar00rootroot00000000000000name: 'Create a binary artifact for Node 22 on Alpine Linux' description: 'Create a binary artifact for Node 22 on Alpine Linux using musl' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-alpine-node-22/entrypoint.sh000077500000000000000000000002301462511572500246160ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-arm64-node-18/000077500000000000000000000000001462511572500215375ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-arm64-node-18/Dockerfile000066400000000000000000000002221462511572500235250ustar00rootroot00000000000000FROM --platform=linux/arm64 node:18-buster RUN apt install python3 make gcc g++ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-arm64-node-18/action.yml000066400000000000000000000005261462511572500235420ustar00rootroot00000000000000name: 'Create a binary artifact for Node == 18 on Linux on ARM64' description: 'Create a binary artifact for Node == 18 on Linux on ARM64 using node:18-buster' inputs: node-version: description: 'Node.js version' required: false default: '18' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-arm64-node-18/entrypoint.sh000077500000000000000000000002301462511572500243040ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-arm64-node-20/000077500000000000000000000000001462511572500215305ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-arm64-node-20/Dockerfile000066400000000000000000000002221462511572500235160ustar00rootroot00000000000000FROM --platform=linux/arm64 node:20-buster RUN apt install python3 make gcc g++ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-arm64-node-20/action.yml000066400000000000000000000005201462511572500235250ustar00rootroot00000000000000name: 'Create a binary artifact for Node 20 on Linux on ARM64' description: 'Create a binary artifact for Node 20 on Linux on ARM64 using node:20-buster' inputs: node-version: description: 'Node.js version' required: false default: '20' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-arm64-node-20/entrypoint.sh000077500000000000000000000002301462511572500242750ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-arm64-node-21/000077500000000000000000000000001462511572500215315ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-arm64-node-21/Dockerfile000066400000000000000000000002241462511572500235210ustar00rootroot00000000000000FROM --platform=linux/arm64 node:21-bullseye RUN apt install python3 make gcc g++ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-arm64-node-21/action.yml000066400000000000000000000005221462511572500235300ustar00rootroot00000000000000name: 'Create a binary artifact for Node 21 on Linux on ARM64' description: 'Create a binary artifact for Node 21 on Linux on ARM64 using node:21-bullseye' inputs: node-version: description: 'Node.js version' required: false default: '21' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-arm64-node-21/entrypoint.sh000077500000000000000000000002301462511572500242760ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-arm64-node-22/000077500000000000000000000000001462511572500215325ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-arm64-node-22/Dockerfile000066400000000000000000000002241462511572500235220ustar00rootroot00000000000000FROM --platform=linux/arm64 node:22-bullseye RUN apt install python3 make gcc g++ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-arm64-node-22/action.yml000066400000000000000000000005221462511572500235310ustar00rootroot00000000000000name: 'Create a binary artifact for Node 22 on Linux on ARM64' description: 'Create a binary artifact for Node 22 on Linux on ARM64 using node:22-bullseye' inputs: node-version: description: 'Node.js version' required: false default: '22' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-arm64-node-22/entrypoint.sh000077500000000000000000000002301462511572500242770ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-node-18/000077500000000000000000000000001462511572500206105ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-node-18/Dockerfile000066400000000000000000000001731462511572500226030ustar00rootroot00000000000000FROM node:18-buster RUN apt install python3 make gcc g++ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-node-18/action.yml000066400000000000000000000005041462511572500226070ustar00rootroot00000000000000name: 'Create a binary artifact for Node == 18 on Linux' description: 'Create a binary artifact for Node == 18 on Linux using node:18-buster' inputs: node-version: description: 'Node.js version' required: false default: '18' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-node-18/entrypoint.sh000077500000000000000000000002301462511572500233550ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-node-20/000077500000000000000000000000001462511572500206015ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-node-20/Dockerfile000066400000000000000000000001731462511572500225740ustar00rootroot00000000000000FROM node:20-buster RUN apt install python3 make gcc g++ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-node-20/action.yml000066400000000000000000000004761462511572500226100ustar00rootroot00000000000000name: 'Create a binary artifact for Node 20 on Linux' description: 'Create a binary artifact for Node 20 on Linux using node:20-buster' inputs: node-version: description: 'Node.js version' required: false default: '20' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-node-20/entrypoint.sh000077500000000000000000000002301462511572500233460ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-node-21/000077500000000000000000000000001462511572500206025ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-node-21/Dockerfile000066400000000000000000000001751462511572500225770ustar00rootroot00000000000000FROM node:21-bullseye RUN apt install python3 make gcc g++ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-node-21/action.yml000066400000000000000000000005001462511572500225750ustar00rootroot00000000000000name: 'Create a binary artifact for Node 21 on Linux' description: 'Create a binary artifact for Node 21 on Linux using node:21-bullseye' inputs: node-version: description: 'Node.js version' required: false default: '21' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-node-21/entrypoint.sh000077500000000000000000000002301462511572500233470ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/actions/linux-node-22/000077500000000000000000000000001462511572500206035ustar00rootroot00000000000000node-re2-1.20.12/.github/actions/linux-node-22/Dockerfile000066400000000000000000000001751462511572500226000ustar00rootroot00000000000000FROM node:22-bullseye RUN apt install python3 make gcc g++ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] node-re2-1.20.12/.github/actions/linux-node-22/action.yml000066400000000000000000000005001462511572500225760ustar00rootroot00000000000000name: 'Create a binary artifact for Node 22 on Linux' description: 'Create a binary artifact for Node 22 on Linux using node:22-bullseye' inputs: node-version: description: 'Node.js version' required: false default: '22' runs: using: 'docker' image: 'Dockerfile' args: - ${{inputs.node-version}} node-re2-1.20.12/.github/actions/linux-node-22/entrypoint.sh000077500000000000000000000002301462511572500233500ustar00rootroot00000000000000#!/bin/sh set -e export USERNAME=`whoami` export DEVELOPMENT_SKIP_GETTING_ASSET=true npm i npm run build --if-present npm test npm run save-to-github node-re2-1.20.12/.github/dependabot.yml000066400000000000000000000007661462511572500175010ustar00rootroot00000000000000# To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 updates: - package-ecosystem: "npm" # See documentation for possible values directory: "/" # Location of package manifests schedule: interval: "weekly" node-re2-1.20.12/.github/workflows/000077500000000000000000000000001462511572500166755ustar00rootroot00000000000000node-re2-1.20.12/.github/workflows/build.yml000066400000000000000000000141741462511572500205260ustar00rootroot00000000000000name: Node.js builds on: push: tags: - v?[0-9]+.[0-9]+.[0-9]+.[0-9]+ - v?[0-9]+.[0-9]+.[0-9]+ - v?[0-9]+.[0-9]+ jobs: create-release: name: Create release runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - env: GH_TOKEN: ${{github.token}} run: | REF=${{github.ref}} TAG=${REF#"refs/tags/"} gh release create -t "Release ${TAG}" -n "" "${{github.ref}}" build: name: Node.js ${{matrix.node-version}} on ${{matrix.os}} needs: create-release runs-on: ${{matrix.os}} strategy: matrix: os: [macos-latest, windows-latest, macos-12] node-version: [18, 20, 21, 22] steps: - uses: actions/checkout@v4 with: submodules: true - name: Setup Node.js ${{matrix.node-version}} uses: actions/setup-node@v4 with: node-version: ${{matrix.node-version}} - name: Install the package and run tests env: DEVELOPMENT_SKIP_GETTING_ASSET: true run: | npm i npm run build --if-present npm test - name: Save to GitHub env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} run: npm run save-to-github build-linux-node-18: name: Node.js 18 on Debian Buster needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Install, test, and create artifact uses: ./.github/actions/linux-node-18/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-node-20: name: Node.js 20 on Debian Buster needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Install, test, and create artifact uses: ./.github/actions/linux-node-20/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-node-21: name: Node.js 21 on Debian Bullseye needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Install, test, and create artifact uses: ./.github/actions/linux-node-21/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-node-22: name: Node.js 22 on Debian Bullseye needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Install, test, and create artifact uses: ./.github/actions/linux-node-22/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-alpine-node-18: name: Node.js 18 on Alpine Linux needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Install, test, and create artifact uses: ./.github/actions/linux-alpine-node-18/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-alpine-node-20: name: Node.js 20 on Alpine Linux needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Install, test, and create artifact uses: ./.github/actions/linux-alpine-node-20/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-alpine-node-21: name: Node.js 21 on Alpine Linux needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Install, test, and create artifact uses: ./.github/actions/linux-alpine-node-21/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-alpine-node-22: name: Node.js 22 on Alpine Linux needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Install, test, and create artifact uses: ./.github/actions/linux-alpine-node-22/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-arm64-node-18: name: Node.js 18 on Debian Buster on ARM64 needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: platforms: arm64 - name: Install, test, and create artifact uses: ./.github/actions/linux-arm64-node-18/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-arm64-node-20: name: Node.js 20 on Debian Buster on ARM64 needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: platforms: arm64 - name: Install, test, and create artifact uses: ./.github/actions/linux-arm64-node-20/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-arm64-node-21: name: Node.js 21 on Debian Bullseye on ARM64 needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: platforms: arm64 - name: Install, test, and create artifact uses: ./.github/actions/linux-arm64-node-21/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} build-linux-arm64-node-22: name: Node.js 22 on Debian Bullseye on ARM64 needs: create-release runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@v4 with: submodules: true - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: platforms: arm64 - name: Install, test, and create artifact uses: ./.github/actions/linux-arm64-node-22/ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} node-re2-1.20.12/.github/workflows/tests.yml000066400000000000000000000013511462511572500205620ustar00rootroot00000000000000name: Node.js CI on: push: branches: ['*'] pull_request: branches: [master] jobs: tests: name: Node.js ${{matrix.node-version}} on ${{matrix.os}} runs-on: ${{matrix.os}} strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] node-version: [18, 20, 21, 22] steps: - uses: actions/checkout@v4 with: submodules: true - name: Setup Node.js ${{matrix.node-version}} uses: actions/setup-node@v4 with: node-version: ${{matrix.node-version}} - name: Install the package and run tests env: DEVELOPMENT_SKIP_GETTING_ASSET: true run: | npm i npm run build --if-present npm test && npm run ts-test node-re2-1.20.12/.gitignore000066400000000000000000000002011462511572500152610ustar00rootroot00000000000000node_modules/ build/ report/ coverage/ .AppleDouble .vscode/ /.development /.developmentx /.xdevelopment /scripts/save-local.sh node-re2-1.20.12/.gitmodules000066400000000000000000000002671462511572500154620ustar00rootroot00000000000000[submodule "vendor/re2"] path = vendor/re2 url = https://github.com/google/re2 [submodule "vendor/abseil-cpp"] path = vendor/abseil-cpp url = https://github.com/abseil/abseil-cpp node-re2-1.20.12/.prettierrc000066400000000000000000000001761462511572500154700ustar00rootroot00000000000000{ "printWidth": 80, "singleQuote": true, "bracketSpacing": false, "arrowParens": "avoid", "trailingComma": "none" } node-re2-1.20.12/LICENSE000066400000000000000000000035651462511572500143160ustar00rootroot00000000000000This library is available under the terms of the modified BSD license. No external contributions are allowed under licenses which are fundamentally incompatible with the BSD license that this library is distributed under. The text of the BSD license is reproduced below. ------------------------------------------------------------------------------- The "New" BSD License: ********************** Copyright (c) 2005-2020, Eugene Lazutkin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Eugene Lazutkin nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. node-re2-1.20.12/README.md000066400000000000000000000435521462511572500145700ustar00rootroot00000000000000# node-re2 [![NPM version][npm-img]][npm-url] [npm-img]: https://img.shields.io/npm/v/re2.svg [npm-url]: https://npmjs.org/package/re2 This project provides bindings for [RE2](https://github.com/google/re2): fast, safe alternative to backtracking regular expression engines written by [Russ Cox](http://swtch.com/~rsc/). To learn more about RE2, start with an overview [Regular Expression Matching in the Wild](http://swtch.com/~rsc/regexp/regexp3.html). More resources can be found at his [Implementing Regular Expressions](http://swtch.com/~rsc/regexp/) page. `RE2`'s regular expression language is almost a superset of what is provided by `RegExp` (see [Syntax](https://github.com/google/re2/wiki/Syntax)), but it lacks two features: backreferences and lookahead assertions. See below for more details. `RE2` always works in the [Unicode mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode), which means that all matches that use character codes are interpret as Unicode code points, not as binary values of UTF-16. See `RE2.unicodeWarningLevel` below for more details. `RE2` object emulates standard `RegExp` making it a practical drop-in replacement in most cases. `RE2` is extended to provide `String`-based regular expression methods as well. To help to convert `RegExp` objects to `RE2` its constructor can take `RegExp` directly honoring all properties. It can work with [node.js buffers](http://nodejs.org/api/buffer.html) directly reducing overhead on recoding and copying characters, and making processing/parsing long files fast. All documentation can be found in this README and in the [wiki](https://github.com/uhop/node-re2/wiki). ## Why use node-re2? The built-in Node.js regular expression engine can run in exponential time with a special combination: - A vulnerable regular expression - "Evil input" This can lead to what is known as a [Regular Expression Denial of Service (ReDoS)](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS). To tell if your regular expressions are vulnerable, you might try the one of these projects: - [rxxr2](http://www.cs.bham.ac.uk/~hxt/research/rxxr2/) - [safe-regex](https://github.com/substack/safe-regex) However, neither project is perfect. node-re2 can protect your Node.js application from ReDoS. node-re2 makes vulnerable regular expression patterns safe by evaluating them in `RE2` instead of the built-in Node.js regex engine. ## Standard features `RE2` object can be created just like `RegExp`: * [`new RE2(pattern[, flags])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) Supported properties: * [`re2.lastIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) * [`re2.global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global) * [`re2.ignoreCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase) * [`re2.multiline`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline) * [`re2.dotAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll) — *since 1.17.6.* * [`re2.unicode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) * `RE2` engine always works in the Unicode mode. See details below. * [`re2.sticky`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky) — *since 1.7.0.* * [`re2.hasIndices`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices) — *since 1.19.0.* * [`re2.source`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source) * [`re2.flags`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags) Supported methods: * [`re2.exec(str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) * [`re2.test(str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) * [`re2.toString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString) Starting with 1.6.0 following well-known symbol-based methods are supported (see [Symbols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol)): * [`re2[Symbol.match](str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match) * [`re2[Symbol.matchAll](str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/matchAll) — *since 1.17.5.* * [`re2[Symbol.search](str)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search) * [`re2[Symbol.replace](str, newSubStr|function)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace) * [`re2[Symbol.split](str[, limit])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split) It allows to use `RE2` instances on strings directly, just like `RegExp` instances: ```js var re = new RE2("1"); "213".match(re); // [ '1', index: 1, input: '213' ] "213".search(re); // 1 "213".replace(re, "+"); // 2+3 "213".split(re); // [ '2', '3' ] Array.from("2131".matchAll(re)); // returns a generator! // [['1', index: 1, input: '2131'], ['1', index: 3, input: '2131']] ``` Starting with 1.8.0 [named groups](https://tc39.github.io/proposal-regexp-named-groups/) are supported. ## Extensions ### Shortcut construction `RE2` object can be created from a regular expression: ```js var re1 = new RE2(/ab*/ig); // from a RegExp object var re2 = new RE2(re1); // from another RE2 object ``` ### `String` methods Standard `String` defines four more methods that can use regular expressions. `RE2` provides them as methods exchanging positions of a string, and a regular expression: * `re2.match(str)` * See [`str.match(regexp)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) * `re2.replace(str, newSubStr|function)` * See [`str.replace(regexp, newSubStr|function)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) * `re2.search(str)` * See [`str.search(regexp)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search) * `re2.split(str[, limit])` * See [`str.split(regexp[, limit])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) Starting with 1.6.0, these methods added as well-known symbol-based methods to be used transparently with ES6 string/regex machinery. ### `Buffer` support In order to support `Buffer` directly, most methods can accept buffers instead of strings. It speeds up all operations. Following signatures are supported: * `re2.exec(buf)` * `re2.test(buf)` * `re2.match(buf)` * `re2.search(buf)` * `re2.split(buf[, limit])` * `re2.replace(buf, replacer)` Differences with their string-based versions: * All buffers are assumed to be encoded as [UTF-8](http://en.wikipedia.org/wiki/UTF-8) (ASCII is a proper subset of UTF-8). * Instead of strings they return `Buffer` objects, even in composite objects. A buffer can be converted to a string with [`buf.toString()`](http://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end). * All offsets and lengths are in bytes, rather than characters (each UTF-8 character can occupy from 1 to 4 bytes). This way users can properly slice buffers without costly recalculations from characters to bytes. When `re2.replace()` is used with a replacer function, the replacer can return a buffer, or a string. But all arguments (except for an input object) will be strings, and an offset will be in characters. If you prefer to deal with buffers and byte offsets in a replacer function, set a property `useBuffers` to `true` on the function: ```js function strReplacer(match, offset, input) { // typeof match == "string" return "<= " + offset + " characters|"; } RE2("б").replace("абв", strReplacer); // "а<= 1 characters|в" function bufReplacer(match, offset, input) { // typeof match == "string" return "<= " + offset + " bytes|"; } bufReplacer.useBuffers = true; RE2("б").replace("абв", bufReplacer); // "а<= 2 bytes|в" ``` This feature works for string and buffer inputs. If a buffer was used as an input, its output will be returned as a buffer too, otherwise a string will be returned. ### Calculate length Two functions to calculate string sizes between [UTF-8](http://en.wikipedia.org/wiki/UTF-8) and [UTF-16](http://en.wikipedia.org/wiki/UTF-16) are exposed on `RE2`: * `RE2.getUtf8Length(str)` — calculates a buffer size in bytes to encode a UTF-16 string as a UTF-8 buffer. * `RE2.getUtf16Length(buf)` — calculates a string size in characters to encode a UTF-8 buffer as a UTF-16 string. JavaScript supports UCS-2 strings with 16-bit characters, while node.js 0.11 supports full UTF-16 as a default string. ### Property: `internalSource` Starting 1.8.0 property `source` emulates the same property of `RegExp`, meaning that it can be used to create an identical `RE2` or `RegExp` instance. Sometimes, for troubleshooting purposes, a user wants to inspect a `RE2` translated source. It is available as a read-only property called `internalSource`. ### Unicode warning level `RE2` engine always works in the Unicode mode. In most cases either there is no difference or the Unicode mode is actually preferred. But sometimes a user wants a tight control over their regular expressions. For those cases, there is a static string property `RE2.unicodeWarningLevel`. Regular expressions in the Unicode mode work as usual. But if a regular expression lacks the Unicode flag, it is always added silently. ```js const x = /./; x.flags; // '' const y = new RE2(x); y.flags; // 'u' ``` In the latter case `RE2` can do following actions depending on `RE2.unicodeWarningLevel`: * `'nothing'` (the default): no warnings or notifications of any kind, a regular expression will be created with `'u'` flag. * `'warnOnce'`: warns exactly once the very first time, a regular expression will be created with `'u'` flag. * Assigning this value resets an internal flag, so `RE2` will warn once again. * `'warn'`: warns every time, a regular expression will be created with `'u'` flag. * `'throw'`: throws a `SyntaxError` every time. * All other warning level values are silently ignored on asignment leaving the previous value unchanged. Warnings and exceptions help to audit an application for stray non-Unicode regular expressions. ## How to install Installation: ``` npm install --save re2 ``` While the project is known to work with other package managers, it is not guaranteed nor tested. For example, [yarn](https://yarnpkg.com/) is known to fail in some scenarios (see this [Wiki article](https://github.com/uhop/node-re2/wiki/Problem:-unusual-errors-with-yarn)). ### Precompiled artifacts When installing re2 the [install script](https://github.com/uhop/install-artifact-from-github/blob/master/bin/install-from-cache.js) attempts to download a prebuilt artifact for your system from the Github releases. The download location can be overridden by setting the `RE2_DOWNLOAD_MIRROR` environment variable as seen in the install script. If all attempts to download the prebuilt artifact for your system fails the script attempts to built re2 locally on your machine using [node-gyp](https://github.com/nodejs/node-gyp). ## How to use It is used just like a `RegExp` object. ```js var RE2 = require("re2"); // with default flags var re = new RE2("a(b*)"); var result = re.exec("abbc"); console.log(result[0]); // "abb" console.log(result[1]); // "bb" result = re.exec("aBbC"); console.log(result[0]); // "a" console.log(result[1]); // "" // with explicit flags re = new RE2("a(b*)", "i"); result = re.exec("aBbC"); console.log(result[0]); // "aBb" console.log(result[1]); // "Bb" // from regular expression object var regexp = new RegExp("a(b*)", "i"); re = new RE2(regexp); result = re.exec("aBbC"); console.log(result[0]); // "aBb" console.log(result[1]); // "Bb" // from regular expression literal re = new RE2(/a(b*)/i); result = re.exec("aBbC"); console.log(result[0]); // "aBb" console.log(result[1]); // "Bb" // from another RE2 object var rex = new RE2(re); result = rex.exec("aBbC"); console.log(result[0]); // "aBb" console.log(result[1]); // "Bb" // shortcut result = new RE2("ab*").exec("abba"); // factory result = RE2("ab*").exec("abba"); ``` ## Limitations (things RE2 does not support) `RE2` consciously avoids any regular expression features that require worst-case exponential time to evaluate. These features are essentially those that describe a Context-Free Language (CFL) rather than a Regular Expression, and are extensions to the traditional regular expression language because some people don't know when enough is enough. The most noteworthy missing features are backreferences and lookahead assertions. If your application uses these features, you should continue to use `RegExp`. But since these features are fundamentally vulnerable to [ReDoS](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS), you should strongly consider replacing them. `RE2` will throw a `SyntaxError` if you try to declare a regular expression using these features. If you are evaluating an externally-provided regular expression, wrap your `RE2` declarations in a try-catch block. It allows to use `RegExp`, when `RE2` misses a feature: ```js var re = /(a)+(b)*/; try { re = new RE2(re); // use RE2 as a drop-in replacement } catch (e) { // suppress an error, and use // the original RegExp } var result = re.exec(sample); ``` In addition to these missing features, `RE2` also behaves somewhat differently from the built-in regular expression engine in corner cases. ### Backreferences `RE2` doesn't support backreferences, which are numbered references to previously matched groups, like so: `\1`, `\2`, and so on. Example of backrefrences: ```js /(cat|dog)\1/.test("catcat"); // true /(cat|dog)\1/.test("dogdog"); // true /(cat|dog)\1/.test("catdog"); // false /(cat|dog)\1/.test("dogcat"); // false ``` ### Lookahead assertions `RE2` doesn't support lookahead assertions, which are ways to allow a matching dependent on subsequent contents. ```js /abc(?=def)/; // match abc only if it is followed by def /abc(?!def)/; // match abc only if it is not followed by def ``` ### Mismatched behavior `RE2` and the built-in regex engines disagree a bit. Before you switch to `RE2`, verify that your regular expressions continue to work as expected. They should do so in the vast majority of cases. Here is an example of a case where they may not: ```js var RE2 = require("../re2"); var pattern = '(?:(a)|(b)|(c))+'; var built_in = new RegExp(pattern); var re2 = new RE2(pattern); var input = 'abc'; var bi_res = built_in.exec(input); var re2_res = re2.exec(input); console.log('bi_res: ' + bi_res); // prints: bi_res: abc,,,c console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c ``` ### Unicode `RE2` always works in the Unicode mode. See `RE2.unicodeWarningLevel` above for more details on how to control warnings about this feature. ## Release history - 1.20.12 *Updated deps. Maintenance chores. Fixes for buffer-related bugs: `exec()` index (reported by [matthewvalentine](https://github.com/matthewvalentine), thx) and `match()` index.* - 1.20.11 *Updated deps. Added support for Node 22 (thx, [Elton Leong](https://github.com/eltonkl)).* - 1.20.10 *Updated deps. Removed files the pack used for development (thx, [Haruaki OTAKE](https://github.com/aaharu)). Added arm64 Linux prebilds (thx, [Christopher M](https://github.com/cmanou)). Fixed non-`npm` `corepack` problem (thx, [Steven](https://github.com/styfle)).* - 1.20.9 *Updated deps. Added more `absail-cpp` files that manifested itself on NixOS. Thx, [Laura Hausmann](https://github.com/zotanmew).* - 1.20.8 *Updated deps: `install-artifact-from-github`. A default HTTPS agent is used for fetching precompiled artifacts avoiding unnecessary long wait times.* - 1.20.7 *Added more `absail-cpp` files that manifested itself on ARM Alpine. Thx, [Laura Hausmann](https://github.com/zotanmew).* - 1.20.6 *Updated deps, notably `node-gyp`.* - 1.20.5 *Updated deps, added Node 21 and retired Node 16 as pre-compilation targets.* - 1.20.4 *Updated deps. Fix: the 2nd argument of the constructor overrides flags. Thx, [gost-serb](https://github.com/gost-serb).* - 1.20.3 *Fix: subsequent numbers are incorporated into group if they would form a legal group reference. Thx, [Oleksii Vasyliev](https://github.com/le0pard).* - 1.20.2 *Fix: added a missing C++ file, which caused a bug on Alpine Linux. Thx, [rbitanga-manticore](https://github.com/rbitanga-manticore).* - 1.20.1 *Fix: files included in the npm package to build the C++ code.* - 1.20.0 *Updated RE2. New version uses `abseil-cpp` and required the adaptation work. Thx, [Stefano Rivera](https://github.com/stefanor).* - 1.19.2 *Bugfix: infinite loop in matchAll() with empty matches. Thx, [ziyunfei](https://github.com/ziyunfei).* - 1.19.1 *Bugfix: indices for the `d` flag when `lastIndex` is non zero. Bugfix: the match result. Thx, [teebu](https://github.com/teebu).* - 1.19.0 *Added `hasIndices` AKA the `d` flag. Thx, [teebu](https://github.com/teebu).* - 1.18.3 *Fixed bug with non-matched groups. Thx, [Dan Setterquist](https://github.com/dset).* - 1.18.2 *Reference to the binary module by its full name.* - 1.18.1 *Support for Node 16, 18, 20 + Darwin arm64 precompiled binaries.* - 1.18.0 *Modified TS bindings, added a type test (thx, [Kenichi Kamiya](https://github.com/kachick) and [Jamie Magee](https://github.com/JamieMagee)).* The rest can be consulted in the project's wiki [Release history](https://github.com/uhop/node-re2/wiki/Release-history). ## License BSD node-re2-1.20.12/binding.gyp000066400000000000000000000145051462511572500154400ustar00rootroot00000000000000{ "targets": [ { "target_name": "re2", "sources": [ "lib/addon.cc", "lib/new.cc", "lib/exec.cc", "lib/test.cc", "lib/match.cc", "lib/replace.cc", "lib/search.cc", "lib/split.cc", "lib/to_string.cc", "lib/accessors.cc", "lib/util.cc", "vendor/re2/re2/bitmap256.cc", "vendor/re2/re2/bitstate.cc", "vendor/re2/re2/compile.cc", "vendor/re2/re2/dfa.cc", "vendor/re2/re2/filtered_re2.cc", "vendor/re2/re2/mimics_pcre.cc", "vendor/re2/re2/nfa.cc", "vendor/re2/re2/onepass.cc", "vendor/re2/re2/parse.cc", "vendor/re2/re2/perl_groups.cc", "vendor/re2/re2/prefilter.cc", "vendor/re2/re2/prefilter_tree.cc", "vendor/re2/re2/prog.cc", "vendor/re2/re2/re2.cc", "vendor/re2/re2/regexp.cc", "vendor/re2/re2/set.cc", "vendor/re2/re2/simplify.cc", "vendor/re2/re2/tostring.cc", "vendor/re2/re2/unicode_casefold.cc", "vendor/re2/re2/unicode_groups.cc", "vendor/re2/util/pcre.cc", "vendor/re2/util/rune.cc", "vendor/re2/util/strutil.cc", "vendor/abseil-cpp/absl/base/internal/cycleclock.cc", "vendor/abseil-cpp/absl/base/internal/low_level_alloc.cc", "vendor/abseil-cpp/absl/base/internal/raw_logging.cc", "vendor/abseil-cpp/absl/base/internal/spinlock.cc", "vendor/abseil-cpp/absl/base/internal/spinlock_wait.cc", "vendor/abseil-cpp/absl/base/internal/sysinfo.cc", "vendor/abseil-cpp/absl/base/internal/thread_identity.cc", "vendor/abseil-cpp/absl/base/internal/throw_delegate.cc", "vendor/abseil-cpp/absl/base/internal/unscaledcycleclock.cc", "vendor/abseil-cpp/absl/debugging/internal/demangle.cc", "vendor/abseil-cpp/absl/container/internal/raw_hash_set.cc", "vendor/abseil-cpp/absl/debugging/internal/address_is_readable.cc", "vendor/abseil-cpp/absl/debugging/internal/elf_mem_image.cc", "vendor/abseil-cpp/absl/debugging/internal/vdso_support.cc", "vendor/abseil-cpp/absl/debugging/stacktrace.cc", "vendor/abseil-cpp/absl/debugging/symbolize.cc", "vendor/abseil-cpp/absl/flags/commandlineflag.cc", "vendor/abseil-cpp/absl/flags/internal/commandlineflag.cc", "vendor/abseil-cpp/absl/flags/internal/flag.cc", "vendor/abseil-cpp/absl/flags/internal/private_handle_accessor.cc", "vendor/abseil-cpp/absl/flags/internal/program_name.cc", "vendor/abseil-cpp/absl/flags/marshalling.cc", "vendor/abseil-cpp/absl/flags/reflection.cc", "vendor/abseil-cpp/absl/flags/usage_config.cc", "vendor/abseil-cpp/absl/hash/internal/city.cc", "vendor/abseil-cpp/absl/hash/internal/hash.cc", "vendor/abseil-cpp/absl/hash/internal/low_level_hash.cc", "vendor/abseil-cpp/absl/numeric/int128.cc", "vendor/abseil-cpp/absl/strings/ascii.cc", "vendor/abseil-cpp/absl/strings/charconv.cc", "vendor/abseil-cpp/absl/strings/internal/charconv_bigint.cc", "vendor/abseil-cpp/absl/strings/internal/charconv_parse.cc", "vendor/abseil-cpp/absl/strings/internal/memutil.cc", "vendor/abseil-cpp/absl/strings/internal/str_format/arg.cc", "vendor/abseil-cpp/absl/strings/internal/str_format/bind.cc", "vendor/abseil-cpp/absl/strings/internal/str_format/extension.cc", "vendor/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc", "vendor/abseil-cpp/absl/strings/internal/str_format/output.cc", "vendor/abseil-cpp/absl/strings/internal/str_format/parser.cc", "vendor/abseil-cpp/absl/strings/match.cc", "vendor/abseil-cpp/absl/strings/numbers.cc", "vendor/abseil-cpp/absl/strings/str_cat.cc", "vendor/abseil-cpp/absl/strings/str_split.cc", "vendor/abseil-cpp/absl/strings/string_view.cc", "vendor/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc", "vendor/abseil-cpp/absl/synchronization/internal/graphcycles.cc", "vendor/abseil-cpp/absl/synchronization/internal/futex_waiter.cc", "vendor/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc", "vendor/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc", "vendor/abseil-cpp/absl/synchronization/internal/waiter_base.cc", "vendor/abseil-cpp/absl/synchronization/mutex.cc", "vendor/abseil-cpp/absl/time/clock.cc", "vendor/abseil-cpp/absl/time/duration.cc", "vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc", "vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc", "vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc", "vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc", "vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc", "vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc", "vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc", "vendor/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc", "vendor/abseil-cpp/absl/time/time.cc", ], "cflags": [ "-std=c++2a", "-Wall", "-Wextra", "-Wno-sign-compare", "-Wno-unused-parameter", "-Wno-missing-field-initializers", "-Wno-cast-function-type", "-O3", "-g" ], "defines": [ "NDEBUG", "NOMINMAX" ], "include_dirs": [ " #include #include NAN_GETTER(WrappedRE2::GetSource) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().Set(Nan::New("(?:)").ToLocalChecked()); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(Nan::New(re2->source).ToLocalChecked()); } NAN_GETTER(WrappedRE2::GetInternalSource) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().Set(Nan::New("(?:)").ToLocalChecked()); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(Nan::New(re2->regexp.pattern()).ToLocalChecked()); } NAN_GETTER(WrappedRE2::GetFlags) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().Set(Nan::New("").ToLocalChecked()); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); std::string flags; if (re2->hasIndices) { flags = "d"; } if (re2->global) { flags += "g"; } if (re2->ignoreCase) { flags += "i"; } if (re2->multiline) { flags += "m"; } if (re2->dotAll) { flags += "s"; } flags += "u"; if (re2->sticky) { flags += "y"; } info.GetReturnValue().Set(Nan::New(flags).ToLocalChecked()); } NAN_GETTER(WrappedRE2::GetGlobal) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().SetUndefined(); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(re2->global); } NAN_GETTER(WrappedRE2::GetIgnoreCase) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().SetUndefined(); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(re2->ignoreCase); } NAN_GETTER(WrappedRE2::GetMultiline) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().SetUndefined(); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(re2->multiline); } NAN_GETTER(WrappedRE2::GetDotAll) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().SetUndefined(); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(re2->dotAll); } NAN_GETTER(WrappedRE2::GetUnicode) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().SetUndefined(); return; } info.GetReturnValue().Set(true); } NAN_GETTER(WrappedRE2::GetSticky) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().SetUndefined(); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(re2->sticky); } NAN_GETTER(WrappedRE2::GetHasIndices) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().SetUndefined(); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(re2->hasIndices); } NAN_GETTER(WrappedRE2::GetLastIndex) { if (!WrappedRE2::HasInstance(info.This())) { info.GetReturnValue().SetUndefined(); return; } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(static_cast(re2->lastIndex)); } NAN_SETTER(WrappedRE2::SetLastIndex) { if (!WrappedRE2::HasInstance(info.This())) { return Nan::ThrowTypeError("Cannot set lastIndex of an invalid RE2 object."); } auto re2 = Nan::ObjectWrap::Unwrap(info.This()); if (value->IsNumber()) { int n = value->NumberValue(Nan::GetCurrentContext()).FromMaybe(0); re2->lastIndex = n <= 0 ? 0 : n; } } WrappedRE2::UnicodeWarningLevels WrappedRE2::unicodeWarningLevel; NAN_GETTER(WrappedRE2::GetUnicodeWarningLevel) { std::string level; switch (unicodeWarningLevel) { case THROW: level = "throw"; break; case WARN: level = "warn"; break; case WARN_ONCE: level = "warnOnce"; break; default: level = "nothing"; break; } info.GetReturnValue().Set(Nan::New(level).ToLocalChecked()); } NAN_SETTER(WrappedRE2::SetUnicodeWarningLevel) { if (value->IsString()) { auto size = Nan::DecodeBytes(value, Nan::UTF8); std::vector buffer(size + 1); auto data = &buffer[0]; Nan::DecodeWrite(data, size, value, Nan::UTF8); buffer[size] = '\0'; if (!strcmp(data, "throw")) { unicodeWarningLevel = THROW; return; } if (!strcmp(data, "warn")) { unicodeWarningLevel = WARN; return; } if (!strcmp(data, "warnOnce")) { unicodeWarningLevel = WARN_ONCE; alreadyWarnedAboutUnicode = false; return; } if (!strcmp(data, "nothing")) { unicodeWarningLevel = NOTHING; return; } } } node-re2-1.20.12/lib/addon.cc000066400000000000000000000063771462511572500154570ustar00rootroot00000000000000#include "./wrapped_re2.h" #include static NAN_METHOD(GetUtf8Length) { auto t = info[0]->ToString(Nan::GetCurrentContext()); if (t.IsEmpty()) { return; } info.GetReturnValue().Set(static_cast(Nan::DecodeBytes(t.ToLocalChecked(), Nan::UTF8))); } static NAN_METHOD(GetUtf16Length) { if (node::Buffer::HasInstance(info[0])) { const auto *s = node::Buffer::Data(info[0]); info.GetReturnValue().Set(static_cast(getUtf16Length(s, s + node::Buffer::Length(info[0])))); return; } info.GetReturnValue().Set(-1); } static void cleanup(void *p) { v8::Isolate *isolate = static_cast(p); auto p_tpl = Nan::GetIsolateData>(isolate); delete p_tpl; } // NAN_MODULE_INIT(WrappedRE2::Init) v8::Local WrappedRE2::Init() { Nan::EscapableHandleScope scope; // prepare constructor template auto tpl = Nan::New(New); tpl->SetClassName(Nan::New("RE2").ToLocalChecked()); auto instanceTemplate = tpl->InstanceTemplate(); instanceTemplate->SetInternalFieldCount(1); // save the template auto isolate = v8::Isolate::GetCurrent(); auto p_tpl = new Nan::Persistent(tpl); Nan::SetIsolateData(isolate, p_tpl); node::AddEnvironmentCleanupHook(isolate, cleanup, isolate); // prototype Nan::SetPrototypeMethod(tpl, "toString", ToString); Nan::SetPrototypeMethod(tpl, "exec", Exec); Nan::SetPrototypeMethod(tpl, "test", Test); Nan::SetPrototypeMethod(tpl, "match", Match); Nan::SetPrototypeMethod(tpl, "replace", Replace); Nan::SetPrototypeMethod(tpl, "search", Search); Nan::SetPrototypeMethod(tpl, "split", Split); Nan::SetPrototypeTemplate(tpl, "source", Nan::New("(?:)").ToLocalChecked()); Nan::SetPrototypeTemplate(tpl, "flags", Nan::New("").ToLocalChecked()); Nan::SetAccessor(instanceTemplate, Nan::New("source").ToLocalChecked(), GetSource); Nan::SetAccessor(instanceTemplate, Nan::New("flags").ToLocalChecked(), GetFlags); Nan::SetAccessor(instanceTemplate, Nan::New("global").ToLocalChecked(), GetGlobal); Nan::SetAccessor(instanceTemplate, Nan::New("ignoreCase").ToLocalChecked(), GetIgnoreCase); Nan::SetAccessor(instanceTemplate, Nan::New("multiline").ToLocalChecked(), GetMultiline); Nan::SetAccessor(instanceTemplate, Nan::New("dotAll").ToLocalChecked(), GetDotAll); Nan::SetAccessor(instanceTemplate, Nan::New("unicode").ToLocalChecked(), GetUnicode); Nan::SetAccessor(instanceTemplate, Nan::New("sticky").ToLocalChecked(), GetSticky); Nan::SetAccessor(instanceTemplate, Nan::New("hasIndices").ToLocalChecked(), GetHasIndices); Nan::SetAccessor(instanceTemplate, Nan::New("lastIndex").ToLocalChecked(), GetLastIndex, SetLastIndex); Nan::SetAccessor(instanceTemplate, Nan::New("internalSource").ToLocalChecked(), GetInternalSource); auto ctr = Nan::GetFunction(tpl).ToLocalChecked(); // properties Nan::Export(ctr, "getUtf8Length", GetUtf8Length); Nan::Export(ctr, "getUtf16Length", GetUtf16Length); Nan::SetAccessor(v8::Local(ctr), Nan::New("unicodeWarningLevel").ToLocalChecked(), GetUnicodeWarningLevel, SetUnicodeWarningLevel); return scope.Escape(ctr); } NODE_MODULE_INIT() { Nan::HandleScope scope; Nan::Set(module->ToObject(context).ToLocalChecked(), Nan::New("exports").ToLocalChecked(), WrappedRE2::Init()); } node-re2-1.20.12/lib/exec.cc000066400000000000000000000115131462511572500153020ustar00rootroot00000000000000#include "./wrapped_re2.h" #include "./util.h" #include #include NAN_METHOD(WrappedRE2::Exec) { // unpack arguments auto re2 = Nan::ObjectWrap::Unwrap(info.This()); if (!re2) { info.GetReturnValue().SetNull(); return; } StrVal str(info[0]); if (!str.data) { return; } size_t lastIndex = 0; if (str.isBuffer) { if ((re2->global || re2->sticky) && re2->lastIndex) { if (re2->lastIndex > str.size) { re2->lastIndex = 0; info.GetReturnValue().SetNull(); return; } lastIndex = re2->lastIndex; } } else { if ((re2->global || re2->sticky) && re2->lastIndex) { if (re2->lastIndex > str.length) { re2->lastIndex = 0; info.GetReturnValue().SetNull(); return; } for (size_t n = re2->lastIndex; n; --n) { size_t s = getUtf8CharSize(str.data[lastIndex]); lastIndex += s; if (s == 4 && n >= 2) --n; // this utf8 character will take two utf16 characters // the decrement above is protected to avoid an overflow of an unsigned integer } } } // actual work std::vector groups(re2->regexp.NumberOfCapturingGroups() + 1); if (!re2->regexp.Match(str, lastIndex, str.size, re2->sticky ? re2::RE2::ANCHOR_START : re2::RE2::UNANCHORED, &groups[0], groups.size())) { if (re2->global || re2->sticky) { re2->lastIndex = 0; } info.GetReturnValue().SetNull(); return; } // form a result auto result = Nan::New(), indices = Nan::New(); int indexOffset = re2->global || re2->sticky ? re2->lastIndex : 0; if (str.isBuffer) { for (size_t i = 0, n = groups.size(); i < n; ++i) { const auto &item = groups[i]; const auto data = item.data(); if (data) { Nan::Set(result, i, Nan::CopyBuffer(data, item.size()).ToLocalChecked()); if (re2->hasIndices) { auto pair = Nan::New(); auto offset = data - str.data - lastIndex; auto length = item.size(); Nan::Set(pair, 0, Nan::New(indexOffset + static_cast(offset))); Nan::Set(pair, 1, Nan::New(indexOffset + static_cast(offset + length))); Nan::Set(indices, i, pair); } } else { Nan::Set(result, i, Nan::Undefined()); if (re2->hasIndices) { Nan::Set(indices, i, Nan::Undefined()); } } } Nan::Set(result, Nan::New("index").ToLocalChecked(), Nan::New(indexOffset + static_cast(groups[0].data() - str.data - lastIndex))); } else { for (size_t i = 0, n = groups.size(); i < n; ++i) { const auto &item = groups[i]; const auto data = item.data(); if (data) { Nan::Set(result, i, Nan::New(data, item.size()).ToLocalChecked()); if (re2->hasIndices) { auto pair = Nan::New(); auto offset = getUtf16Length(str.data + lastIndex, data); auto length = getUtf16Length(data, data + item.size()); Nan::Set(pair, 0, Nan::New(indexOffset + static_cast(offset))); Nan::Set(pair, 1, Nan::New(indexOffset + static_cast(offset + length))); Nan::Set(indices, i, pair); } } else { Nan::Set(result, i, Nan::Undefined()); if (re2->hasIndices) { Nan::Set(indices, i, Nan::Undefined()); } } } Nan::Set(result, Nan::New("index").ToLocalChecked(), Nan::New(indexOffset + static_cast(getUtf16Length(str.data + lastIndex, groups[0].data())))); } if (re2->global || re2->sticky) { re2->lastIndex += str.isBuffer ? groups[0].data() - str.data + groups[0].size() - lastIndex : getUtf16Length(str.data + lastIndex, groups[0].data() + groups[0].size()); } Nan::Set(result, Nan::New("input").ToLocalChecked(), info[0]); const auto &groupNames = re2->regexp.CapturingGroupNames(); if (!groupNames.empty()) { auto groups = Nan::New(); Nan::SetPrototype(groups, Nan::Null()); for (auto group : groupNames) { auto value = Nan::Get(result, group.first); if (!value.IsEmpty()) { Nan::Set(groups, Nan::New(group.second).ToLocalChecked(), value.ToLocalChecked()); } } Nan::Set(result, Nan::New("groups").ToLocalChecked(), groups); if (re2->hasIndices) { auto indexGroups = Nan::New(); Nan::SetPrototype(indexGroups, Nan::Null()); for (auto group : groupNames) { auto value = Nan::Get(indices, group.first); if (!value.IsEmpty()) { Nan::Set(indexGroups, Nan::New(group.second).ToLocalChecked(), value.ToLocalChecked()); } } Nan::Set(indices, Nan::New("groups").ToLocalChecked(), indexGroups); } } else { Nan::Set(result, Nan::New("groups").ToLocalChecked(), Nan::Undefined()); if (re2->hasIndices) { Nan::Set(indices, Nan::New("groups").ToLocalChecked(), Nan::Undefined()); } } if (re2->hasIndices) { Nan::Set(result, Nan::New("indices").ToLocalChecked(), indices); } info.GetReturnValue().Set(result); } node-re2-1.20.12/lib/match.cc000066400000000000000000000117651462511572500154630ustar00rootroot00000000000000#include "./wrapped_re2.h" #include "./util.h" #include NAN_METHOD(WrappedRE2::Match) { // unpack arguments auto re2 = Nan::ObjectWrap::Unwrap(info.This()); if (!re2) { info.GetReturnValue().SetNull(); return; } StrVal a(info[0]); if (!a.data) { return; } std::vector groups; re2::StringPiece str(a); size_t lastIndex = 0; auto anchor = re2::RE2::UNANCHORED; // actual work if (re2->global) { // global: collect all matches re2::StringPiece match; if (re2->sticky) { anchor = re2::RE2::ANCHOR_START; } while (re2->regexp.Match(str, lastIndex, a.size, anchor, &match, 1)) { groups.push_back(match); lastIndex = match.data() - a.data + match.size(); } if (groups.empty()) { info.GetReturnValue().SetNull(); return; } } else { // non-global: just like exec() if (re2->sticky) { for (size_t n = re2->lastIndex; n; --n) { size_t s = getUtf8CharSize(a.data[lastIndex]); lastIndex += s; if (s == 4 && n >= 2) --n; // this utf8 character will take two utf16 characters // the decrement above is protected to avoid an overflow of an unsigned integer } anchor = RE2::ANCHOR_START; } groups.resize(re2->regexp.NumberOfCapturingGroups() + 1); if (!re2->regexp.Match(str, lastIndex, a.size, anchor, &groups[0], groups.size())) { if (re2->sticky) { re2->lastIndex = 0; } info.GetReturnValue().SetNull(); return; } } // form a result auto result = Nan::New(), indices = Nan::New(); if (a.isBuffer) { for (size_t i = 0, n = groups.size(); i < n; ++i) { const auto &item = groups[i]; const auto data = item.data(); if (data) { Nan::Set(result, i, Nan::CopyBuffer(data, item.size()).ToLocalChecked()); if (!re2->global && re2->hasIndices) { auto pair = Nan::New(); auto offset = data - a.data - lastIndex; auto length = item.size(); Nan::Set(pair, 0, Nan::New(static_cast(offset))); Nan::Set(pair, 1, Nan::New(static_cast(offset + length))); Nan::Set(indices, i, pair); } } else { Nan::Set(result, i, Nan::Undefined()); if (!re2->global && re2->hasIndices) { Nan::Set(indices, i, Nan::Undefined()); } } } if (!re2->global) { Nan::Set(result, Nan::New("index").ToLocalChecked(), Nan::New(static_cast(groups[0].data() - a.data))); Nan::Set(result, Nan::New("input").ToLocalChecked(), info[0]); } } else { for (size_t i = 0, n = groups.size(); i < n; ++i) { const auto &item = groups[i]; const auto data = item.data(); if (data) { Nan::Set(result, i, Nan::New(data, item.size()).ToLocalChecked()); if (!re2->global && re2->hasIndices) { auto pair = Nan::New(); auto offset = getUtf16Length(a.data + lastIndex, data); auto length = getUtf16Length(data, data + item.size()); Nan::Set(pair, 0, Nan::New(static_cast(offset))); Nan::Set(pair, 1, Nan::New(static_cast(offset + length))); Nan::Set(indices, i, pair); } } else { Nan::Set(result, i, Nan::Undefined()); if (!re2->global && re2->hasIndices) { Nan::Set(indices, i, Nan::Undefined()); } } } if (!re2->global) { Nan::Set(result, Nan::New("index").ToLocalChecked(), Nan::New(static_cast(getUtf16Length(a.data, groups[0].data())))); Nan::Set(result, Nan::New("input").ToLocalChecked(), info[0]); } } if (re2->global) { re2->lastIndex = 0; } else if (re2->sticky) { re2->lastIndex += a.isBuffer ? groups[0].data() - a.data + groups[0].size() - lastIndex : getUtf16Length(a.data + lastIndex, groups[0].data() + groups[0].size()); } if (!re2->global) { const auto &groupNames = re2->regexp.CapturingGroupNames(); if (!groupNames.empty()) { auto groups = Nan::New(); Nan::SetPrototype(groups, Nan::Null()); for (auto group : groupNames) { auto value = Nan::Get(result, group.first); if (!value.IsEmpty()) { Nan::Set(groups, Nan::New(group.second).ToLocalChecked(), value.ToLocalChecked()); } } Nan::Set(result, Nan::New("groups").ToLocalChecked(), groups); if (re2->hasIndices) { auto indexGroups = Nan::New(); Nan::SetPrototype(indexGroups, Nan::Null()); for (auto group : groupNames) { auto value = Nan::Get(indices, group.first); if (!value.IsEmpty()) { Nan::Set(indexGroups, Nan::New(group.second).ToLocalChecked(), value.ToLocalChecked()); } } Nan::Set(indices, Nan::New("groups").ToLocalChecked(), indexGroups); } } else { Nan::Set(result, Nan::New("groups").ToLocalChecked(), Nan::Undefined()); if (re2->hasIndices) { Nan::Set(indices, Nan::New("groups").ToLocalChecked(), Nan::Undefined()); } } if (re2->hasIndices) { Nan::Set(result, Nan::New("indices").ToLocalChecked(), indices); } } info.GetReturnValue().Set(result); } node-re2-1.20.12/lib/new.cc000066400000000000000000000213041462511572500151460ustar00rootroot00000000000000#include "./wrapped_re2.h" #include "./util.h" #include #include #include #include static char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; inline bool isUpperCaseAlpha(char ch) { return 'A' <= ch && ch <= 'Z'; } inline bool isHexadecimal(char ch) { return ('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z'); } static bool translateRegExp(const char *data, size_t size, bool multiline, std::vector &buffer) { std::string result; bool changed = false; if (!size) { result = "(?:)"; changed = true; } else if (multiline) { result = "(?m)"; changed = true; } for (size_t i = 0; i < size;) { char ch = data[i]; if (ch == '\\') { if (i + 1 < size) { ch = data[i + 1]; switch (ch) { case '\\': result += "\\\\"; i += 2; continue; case 'c': if (i + 2 < size) { ch = data[i + 2]; if (isUpperCaseAlpha(ch)) { result += "\\x"; result += hex[((ch - '@') / 16) & 15]; result += hex[(ch - '@') & 15]; i += 3; changed = true; continue; } } result += "\\c"; i += 2; continue; case 'u': if (i + 2 < size) { ch = data[i + 2]; if (isHexadecimal(ch)) { result += "\\x{"; result += ch; i += 3; for (size_t j = 0; j < 3 && i < size; ++i, ++j) { ch = data[i]; if (!isHexadecimal(ch)) { break; } result += ch; } result += '}'; changed = true; continue; } else if (ch == '{') { result += "\\x"; i += 2; changed = true; continue; } } result += "\\u"; i += 2; continue; default: result += "\\"; size_t sym_size = getUtf8CharSize(ch); result.append(data + i + 1, sym_size); i += sym_size + 1; continue; } } } else if (ch == '/') { result += "\\/"; i += 1; changed = true; continue; } else if (ch == '(' && i + 2 < size && data[i + 1] == '?' && data[i + 2] == '<') { if (i + 3 >= size || (data[i + 3] != '=' && data[i + 3] != '!')) { result += "(?P<"; i += 3; changed = true; continue; } } size_t sym_size = getUtf8CharSize(ch); result.append(data + i, sym_size); i += sym_size; } if (!changed) { return false; } buffer.resize(0); buffer.insert(buffer.end(), result.data(), result.data() + result.size()); buffer.push_back('\0'); return true; } static std::string escapeRegExp(const char *data, size_t size) { std::string result; if (!size) { result = "(?:)"; } size_t prevBackSlashes = 0; for (size_t i = 0; i < size;) { char ch = data[i]; if (ch == '\\') { ++prevBackSlashes; } else if (ch == '/' && !(prevBackSlashes & 1)) { result += "\\/"; i += 1; prevBackSlashes = 0; continue; } else { prevBackSlashes = 0; } size_t sym_size = getUtf8CharSize(ch); result.append(data + i, sym_size); i += sym_size; } return result; } bool WrappedRE2::alreadyWarnedAboutUnicode = false; static const char *deprecationMessage = "BMP patterns aren't supported by node-re2. An implicit \"u\" flag is assumed by the RE2 constructor. In a future major version, calling the RE2 constructor without the \"u\" flag may become forbidden, or cause a different behavior. Please see https://github.com/uhop/node-re2/issues/21 for more information."; inline bool ensureUniqueNamedGroups(const std::map &groups) { std::unordered_set names; for (auto group : groups) { if (!names.insert(group.second).second) { return false; } } return true; } NAN_METHOD(WrappedRE2::New) { if (!info.IsConstructCall()) { // call a constructor and return the result std::vector> parameters(info.Length()); for (size_t i = 0, n = info.Length(); i < n; ++i) { parameters[i] = info[i]; } auto isolate = v8::Isolate::GetCurrent(); auto p_tpl = Nan::GetIsolateData>(isolate); auto newObject = Nan::NewInstance(Nan::GetFunction(p_tpl->Get(isolate)).ToLocalChecked(), parameters.size(), ¶meters[0]); if (!newObject.IsEmpty()) { info.GetReturnValue().Set(newObject.ToLocalChecked()); } return; } // process arguments std::vector buffer; char *data = NULL; size_t size = 0; std::string source; bool global = false; bool ignoreCase = false; bool multiline = false; bool dotAll = false; bool unicode = false; bool sticky = false; bool hasIndices = false; auto context = Nan::GetCurrentContext(); bool needFlags = true; if (info.Length() > 1) { if (info[1]->IsString()) { size = Nan::DecodeBytes(info[1], Nan::UTF8); buffer.resize(size + 1); data = &buffer[0]; Nan::DecodeWrite(data, size, info[1], Nan::UTF8); buffer[size] = '\0'; } else if (node::Buffer::HasInstance(info[1])) { size = node::Buffer::Length(info[1]); data = node::Buffer::Data(info[1]); } for (size_t i = 0; i < size; ++i) { switch (data[i]) { case 'g': global = true; break; case 'i': ignoreCase = true; break; case 'm': multiline = true; break; case 's': dotAll = true; break; case 'u': unicode = true; break; case 'y': sticky = true; break; case 'd': hasIndices = true; break; } } size = 0; needFlags = false; } bool needConversion = true; if (node::Buffer::HasInstance(info[0])) { size = node::Buffer::Length(info[0]); data = node::Buffer::Data(info[0]); source = escapeRegExp(data, size); } else if (info[0]->IsRegExp()) { const auto *re = v8::RegExp::Cast(*info[0]); auto t = re->GetSource(); size = Nan::DecodeBytes(t, Nan::UTF8); buffer.resize(size + 1); data = &buffer[0]; Nan::DecodeWrite(data, size, t, Nan::UTF8); buffer[size] = '\0'; source = escapeRegExp(data, size); if (needFlags) { v8::RegExp::Flags flags = re->GetFlags(); global = bool(flags & v8::RegExp::kGlobal); ignoreCase = bool(flags & v8::RegExp::kIgnoreCase); multiline = bool(flags & v8::RegExp::kMultiline); dotAll = bool(flags & v8::RegExp::kDotAll); unicode = bool(flags & v8::RegExp::kUnicode); sticky = bool(flags & v8::RegExp::kSticky); hasIndices = bool(flags & v8::RegExp::kHasIndices); needFlags = false; } } else if (info[0]->IsObject() && !info[0]->IsString()) { WrappedRE2 *re2 = nullptr; auto object = info[0]->ToObject(context).ToLocalChecked(); if (!object.IsEmpty() && object->InternalFieldCount() > 0) { re2 = Nan::ObjectWrap::Unwrap(object); } if (re2) { const auto &pattern = re2->regexp.pattern(); size = pattern.size(); buffer.resize(size); data = &buffer[0]; memcpy(data, pattern.data(), size); needConversion = false; source = re2->source; if (needFlags) { global = re2->global; ignoreCase = re2->ignoreCase; multiline = re2->multiline; dotAll = re2->dotAll; unicode = true; sticky = re2->sticky; hasIndices = re2->hasIndices; needFlags = false; } } } else if (info[0]->IsString()) { size = Nan::DecodeBytes(info[0], Nan::UTF8); buffer.resize(size + 1); data = &buffer[0]; Nan::DecodeWrite(data, size, info[0], Nan::UTF8); buffer[size] = '\0'; source = escapeRegExp(data, size); } if (!data) { return Nan::ThrowTypeError("Expected string, Buffer, RegExp, or RE2 as the 1st argument."); } if (!unicode) { switch (unicodeWarningLevel) { case THROW: return Nan::ThrowSyntaxError(deprecationMessage); case WARN: printDeprecationWarning(deprecationMessage); break; case WARN_ONCE: if (!alreadyWarnedAboutUnicode) { printDeprecationWarning(deprecationMessage); alreadyWarnedAboutUnicode = true; } break; default: break; } } if (needConversion && translateRegExp(data, size, multiline, buffer)) { size = buffer.size() - 1; data = &buffer[0]; } // create and return an object re2::RE2::Options options; options.set_case_sensitive(!ignoreCase); options.set_one_line(!multiline); // to track this state, otherwise it is ignored options.set_dot_nl(dotAll); options.set_log_errors(false); // inappropriate when embedding std::unique_ptr re2(new WrappedRE2(re2::StringPiece(data, size), options, source, global, ignoreCase, multiline, dotAll, sticky, hasIndices)); if (!re2->regexp.ok()) { return Nan::ThrowSyntaxError(re2->regexp.error().c_str()); } if (!ensureUniqueNamedGroups(re2->regexp.CapturingGroupNames())) { return Nan::ThrowSyntaxError("duplicate capture group name"); } re2->Wrap(info.This()); re2.release(); info.GetReturnValue().Set(info.This()); } node-re2-1.20.12/lib/replace.cc000066400000000000000000000276561462511572500160100ustar00rootroot00000000000000#include "./wrapped_re2.h" #include "./util.h" #include #include #include #include #include inline int getMaxSubmatch(const char *data, size_t size, const std::map &namedGroups) { int maxSubmatch = 0, index, index2; const char *nameBegin; const char *nameEnd; for (size_t i = 0; i < size;) { char ch = data[i]; if (ch == '$') { if (i + 1 < size) { ch = data[i + 1]; switch (ch) { case '$': case '&': case '`': case '\'': i += 2; continue; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': index = ch - '0'; if (i + 2 < size) { ch = data[i + 2]; if ('0' <= ch && ch <= '9') { index2 = index * 10 + (ch - '0'); if (maxSubmatch < index2) maxSubmatch = index2; i += 3; continue; } } if (maxSubmatch < index) maxSubmatch = index; i += 2; continue; case '<': nameBegin = data + i + 2; nameEnd = (const char *)memchr(nameBegin, '>', size - i - 2); if (nameEnd) { std::string name(nameBegin, nameEnd - nameBegin); auto group = namedGroups.find(name); if (group != namedGroups.end()) { index = group->second; if (maxSubmatch < index) maxSubmatch = index; } i = nameEnd + 1 - data; } else { i += 2; } continue; } } ++i; continue; } i += getUtf8CharSize(ch); } return maxSubmatch; } inline std::string replace(const char *data, size_t size, const std::vector &groups, const re2::StringPiece &str, const std::map &namedGroups) { std::string result; size_t index, index2; const char *nameBegin; const char *nameEnd; for (size_t i = 0; i < size;) { char ch = data[i]; if (ch == '$') { if (i + 1 < size) { ch = data[i + 1]; switch (ch) { case '$': result += ch; i += 2; continue; case '&': result += (std::string)groups[0]; i += 2; continue; case '`': result += std::string(str.data(), groups[0].data() - str.data()); i += 2; continue; case '\'': result += std::string(groups[0].data() + groups[0].size(), str.data() + str.size() - groups[0].data() - groups[0].size()); i += 2; continue; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': index = ch - '0'; if (i + 2 < size) { ch = data[i + 2]; if ('0' <= ch && ch <= '9') { i += 3; index2 = index * 10 + (ch - '0'); if (index2 && index2 < groups.size()) { result += (std::string)groups[index2]; continue; } else if (index && index < groups.size()) { result += (std::string)groups[index]; result += ch; continue; } result += '$'; result += '0' + index; result += ch; continue; } ch = '0' + index; } i += 2; if (index && index < groups.size()) { result += (std::string)groups[index]; continue; } result += '$'; result += ch; continue; case '<': if (!namedGroups.empty()) { nameBegin = data + i + 2; nameEnd = (const char *)memchr(nameBegin, '>', size - i - 2); if (nameEnd) { std::string name(nameBegin, nameEnd - nameBegin); auto group = namedGroups.find(name); if (group != namedGroups.end()) { index = group->second; result += (std::string)groups[index]; } i = nameEnd + 1 - data; } else { result += "$<"; i += 2; } } else { result += "$<"; i += 2; } continue; } } result += '$'; ++i; continue; } size_t sym_size = getUtf8CharSize(ch); result.append(data + i, sym_size); i += sym_size; } return result; } static Nan::Maybe replace(WrappedRE2 *re2, const StrVal &replacee, const char *replacer, size_t replacer_size) { const re2::StringPiece str = replacee; const char *data = str.data(); size_t size = str.size(); const auto &namedGroups = re2->regexp.NamedCapturingGroups(); std::vector groups(std::min(re2->regexp.NumberOfCapturingGroups(), getMaxSubmatch(replacer, replacer_size, namedGroups)) + 1); const auto &match = groups[0]; size_t lastIndex = 0; std::string result; auto anchor = re2::RE2::UNANCHORED; if (re2->sticky) { if (!re2->global) { if (replacee.isBuffer) { lastIndex = re2->lastIndex; } else { for (size_t n = re2->lastIndex; n; --n) { size_t s = getUtf8CharSize(data[lastIndex]); lastIndex += s; if (s == 4 && n >= 2) { --n; // this utf8 character will take two utf16 characters } // the decrement above is protected to avoid an overflow of an unsigned integer } } } anchor = re2::RE2::ANCHOR_START; } if (lastIndex) { result = std::string(data, lastIndex); } bool noMatch = true; while (lastIndex <= size && re2->regexp.Match(str, lastIndex, size, anchor, &groups[0], groups.size())) { noMatch = false; auto offset = match.data() - data; if (!re2->global && re2->sticky) { re2->lastIndex += replacee.isBuffer ? offset + match.size() - lastIndex : getUtf16Length(data + lastIndex, match.data() + match.size()); } if (match.data() == data || offset > static_cast(lastIndex)) { result += std::string(data + lastIndex, offset - lastIndex); } result += replace(replacer, replacer_size, groups, str, namedGroups); if (match.size()) { lastIndex = offset + match.size(); } else if ((size_t)offset < size) { auto sym_size = getUtf8CharSize(data[offset]); result.append(data + offset, sym_size); lastIndex = offset + sym_size; } else { lastIndex = size; break; } if (!re2->global) { break; } } if (lastIndex < size) { result += std::string(data + lastIndex, size - lastIndex); } if (re2->global) { re2->lastIndex = 0; } else if (re2->sticky) { if (noMatch) { re2->lastIndex = 0; } } return Nan::Just(result); } inline Nan::Maybe replace(const Nan::Callback *replacer, const std::vector &groups, const re2::StringPiece &str, const v8::Local &input, bool useBuffers, const std::map &namedGroups) { std::vector> argv; auto context = Nan::GetCurrentContext(); if (useBuffers) { for (size_t i = 0, n = groups.size(); i < n; ++i) { const auto &item = groups[i]; const auto data = item.data(); if (data) { argv.push_back(Nan::CopyBuffer(data, item.size()).ToLocalChecked()); } else { argv.push_back(Nan::Undefined()); } } argv.push_back(Nan::New(static_cast(groups[0].data() - str.data()))); } else { for (size_t i = 0, n = groups.size(); i < n; ++i) { const auto &item = groups[i]; const auto data = item.data(); if (data) { argv.push_back(Nan::New(data, item.size()).ToLocalChecked()); } else { argv.push_back(Nan::Undefined()); } } argv.push_back(Nan::New(static_cast(getUtf16Length(str.data(), groups[0].data())))); } argv.push_back(input); if (!namedGroups.empty()) { auto groups = Nan::New(); Nan::SetPrototype(groups, Nan::Null()); for (std::pair group : namedGroups) { Nan::Set(groups, Nan::New(group.first).ToLocalChecked(), argv[group.second]); } argv.push_back(groups); } auto maybeResult = Nan::CallAsFunction(replacer->GetFunction(), context->Global(), static_cast(argv.size()), &argv[0]); if (maybeResult.IsEmpty()) { return Nan::Nothing(); } auto result = maybeResult.ToLocalChecked(); if (node::Buffer::HasInstance(result)) { return Nan::Just(std::string(node::Buffer::Data(result), node::Buffer::Length(result))); } StrVal val = result; return Nan::Just(std::string(val.data, val.size)); } static Nan::Maybe replace(WrappedRE2 *re2, const StrVal &replacee, const Nan::Callback *replacer, const v8::Local &input, bool useBuffers) { const re2::StringPiece str = replacee; const char *data = str.data(); size_t size = str.size(); std::vector groups(re2->regexp.NumberOfCapturingGroups() + 1); const auto &match = groups[0]; size_t lastIndex = 0; std::string result; auto anchor = re2::RE2::UNANCHORED; if (re2->sticky) { if (!re2->global) { if (replacee.isBuffer) { lastIndex = re2->lastIndex; } else { for (size_t n = re2->lastIndex; n; --n) { size_t s = getUtf8CharSize(data[lastIndex]); lastIndex += s; if (s == 4 && n >= 2) { --n; // this utf8 character will take two utf16 characters } // the decrement above is protected to avoid an overflow of an unsigned integer } } } anchor = RE2::ANCHOR_START; } if (lastIndex) { result = std::string(data, lastIndex); } const auto &namedGroups = re2->regexp.NamedCapturingGroups(); bool noMatch = true; while (lastIndex <= size && re2->regexp.Match(str, lastIndex, size, anchor, &groups[0], groups.size())) { noMatch = false; auto offset = match.data() - data; if (!re2->global && re2->sticky) { re2->lastIndex += replacee.isBuffer ? offset + match.size() - lastIndex : getUtf16Length(data + lastIndex, match.data() + match.size()); } if (match.data() == data || offset > static_cast(lastIndex)) { result += std::string(data + lastIndex, offset - lastIndex); } const auto part = replace(replacer, groups, str, input, useBuffers, namedGroups); if (part.IsNothing()) { return part; } result += part.FromJust(); if (match.size()) { lastIndex = offset + match.size(); } else if ((size_t)offset < size) { auto sym_size = getUtf8CharSize(data[offset]); result.append(data + offset, sym_size); lastIndex = offset + sym_size; } else { lastIndex = size; break; } if (!re2->global) { break; } } if (lastIndex < size) { result += std::string(data + lastIndex, size - lastIndex); } if (re2->global) { re2->lastIndex = 0; } else if (re2->sticky) { if (noMatch) { re2->lastIndex = 0; } } return Nan::Just(result); } static bool requiresBuffers(const v8::Local &f) { auto flag(Nan::Get(f, Nan::New("useBuffers").ToLocalChecked()).ToLocalChecked()); if (flag->IsUndefined() || flag->IsNull() || flag->IsFalse()) { return false; } if (flag->IsNumber()) { return flag->NumberValue(Nan::GetCurrentContext()).FromMaybe(0) != 0; } if (flag->IsString()) { return flag->ToString(Nan::GetCurrentContext()).ToLocalChecked()->Length() > 0; } return true; } NAN_METHOD(WrappedRE2::Replace) { auto re2 = Nan::ObjectWrap::Unwrap(info.This()); if (!re2) { info.GetReturnValue().Set(info[0]); return; } StrVal replacee = info[0]; if (!replacee.data) { info.GetReturnValue().Set(info[0]); return; } std::string result; if (info[1]->IsFunction()) { auto fun = info[1].As(); const std::unique_ptr cb(new Nan::Callback(fun)); const auto replaced = replace(re2, replacee, cb.get(), info[0], requiresBuffers(fun)); if (replaced.IsNothing()) { info.GetReturnValue().Set(info[0]); return; } result = replaced.FromJust(); } else { StrVal replacer = info[1]; if (!replacer.data) { info.GetReturnValue().Set(info[0]); return; } const auto replaced = replace(re2, replacee, replacer.data, replacer.size); if (replaced.IsNothing()) { info.GetReturnValue().Set(info[0]); return; } result = replaced.FromJust(); } if (replacee.isBuffer) { info.GetReturnValue().Set(Nan::CopyBuffer(result.data(), result.size()).ToLocalChecked()); return; } info.GetReturnValue().Set(Nan::New(result).ToLocalChecked()); } node-re2-1.20.12/lib/search.cc000066400000000000000000000011351462511572500156220ustar00rootroot00000000000000#include "./wrapped_re2.h" #include "./util.h" NAN_METHOD(WrappedRE2::Search) { // unpack arguments auto re2 = Nan::ObjectWrap::Unwrap(info.This()); if (!re2) { info.GetReturnValue().Set(-1); return; } StrVal a = info[0]; if (!a.data) { return; } // actual work re2::StringPiece match; if (re2->regexp.Match(a, 0, a.size, re2->sticky ? re2::RE2::ANCHOR_START : re2::RE2::UNANCHORED, &match, 1)) { info.GetReturnValue().Set(static_cast(a.isBuffer ? match.data() - a.data : getUtf16Length(a.data, match.data()))); return; } info.GetReturnValue().Set(-1); } node-re2-1.20.12/lib/split.cc000066400000000000000000000041611462511572500155120ustar00rootroot00000000000000#include "./wrapped_re2.h" #include "./util.h" #include #include #include NAN_METHOD(WrappedRE2::Split) { auto result = Nan::New(); // unpack arguments auto re2 = Nan::ObjectWrap::Unwrap(info.This()); if (!re2) { Nan::Set(result, 0, info[0]); info.GetReturnValue().Set(result); return; } StrVal a = info[0]; if (!a.data) { return; } re2::StringPiece str = a; size_t limit = std::numeric_limits::max(); if (info.Length() > 1 && info[1]->IsNumber()) { size_t lim = info[1]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0); if (lim > 0) { limit = lim; } } // actual work std::vector groups(re2->regexp.NumberOfCapturingGroups() + 1), pieces; const auto &match = groups[0]; size_t lastIndex = 0; while (lastIndex < a.size && re2->regexp.Match(str, lastIndex, a.size, RE2::UNANCHORED, &groups[0], groups.size())) { if (match.size()) { pieces.push_back(re2::StringPiece(a.data + lastIndex, match.data() - a.data - lastIndex)); lastIndex = match.data() - a.data + match.size(); pieces.insert(pieces.end(), groups.begin() + 1, groups.end()); } else { size_t sym_size = getUtf8CharSize(a.data[lastIndex]); pieces.push_back(re2::StringPiece(a.data + lastIndex, sym_size)); lastIndex += sym_size; } if (pieces.size() >= limit) { break; } } if (pieces.size() < limit && (lastIndex < a.size || (lastIndex == a.size && match.size()))) { pieces.push_back(re2::StringPiece(a.data + lastIndex, a.size - lastIndex)); } if (pieces.empty()) { Nan::Set(result, 0, info[0]); info.GetReturnValue().Set(result); return; } // form a result if (a.isBuffer) { for (size_t i = 0, n = std::min(pieces.size(), limit); i < n; ++i) { const auto &item = pieces[i]; Nan::Set(result, i, Nan::CopyBuffer(item.data(), item.size()).ToLocalChecked()); } } else { for (size_t i = 0, n = std::min(pieces.size(), limit); i < n; ++i) { const auto &item = pieces[i]; Nan::Set(result, i, Nan::New(item.data(), item.size()).ToLocalChecked()); } } info.GetReturnValue().Set(result); } node-re2-1.20.12/lib/test.cc000066400000000000000000000032061462511572500153350ustar00rootroot00000000000000#include "./wrapped_re2.h" #include "./util.h" #include #include NAN_METHOD(WrappedRE2::Test) { // unpack arguments auto re2 = Nan::ObjectWrap::Unwrap(info.This()); if (!re2) { info.GetReturnValue().Set(false); return; } StrVal str = info[0]; if (!str.data) { return; } size_t lastIndex = 0; if (str.isBuffer) { if ((re2->global || re2->sticky) && re2->lastIndex) { if (re2->lastIndex > str.size) { re2->lastIndex = 0; info.GetReturnValue().Set(false); return; } lastIndex = re2->lastIndex; } } else { if ((re2->global || re2->sticky) && re2->lastIndex) { if (re2->lastIndex > str.length) { re2->lastIndex = 0; info.GetReturnValue().Set(false); return; } for (size_t n = re2->lastIndex; n; --n) { size_t s = getUtf8CharSize(str.data[lastIndex]); lastIndex += s; if (s == 4 && n >= 2) --n; // this utf8 character will take two utf16 characters // the decrement above is protected to avoid an overflow of an unsigned integer } } } // actual work if (re2->global || re2->sticky) { re2::StringPiece match; if (re2->regexp.Match(str, lastIndex, str.size, re2->sticky ? re2::RE2::ANCHOR_START : re2::RE2::UNANCHORED, &match, 1)) { re2->lastIndex += str.isBuffer ? match.data() - str.data + match.size() - lastIndex : getUtf16Length(str.data + lastIndex, match.data() + match.size()); info.GetReturnValue().Set(true); return; } re2->lastIndex = 0; info.GetReturnValue().Set(false); return; } info.GetReturnValue().Set(re2->regexp.Match(str, lastIndex, str.size, re2::RE2::UNANCHORED, NULL, 0)); } node-re2-1.20.12/lib/to_string.cc000066400000000000000000000011471462511572500163700ustar00rootroot00000000000000#include "./wrapped_re2.h" #include NAN_METHOD(WrappedRE2::ToString) { // unpack arguments auto re2 = Nan::ObjectWrap::Unwrap(info.This()); if (!re2) { info.GetReturnValue().SetEmptyString(); return; } // actual work std::string buffer("/"); buffer += re2->source; buffer += "/"; if (re2->global) { buffer += "g"; } if (re2->ignoreCase) { buffer += "i"; } if (re2->multiline) { buffer += "m"; } if (re2->dotAll) { buffer += "s"; } buffer += "u"; if (re2->sticky) { buffer += "y"; } info.GetReturnValue().Set(Nan::New(buffer).ToLocalChecked()); } node-re2-1.20.12/lib/util.cc000066400000000000000000000050221462511572500153310ustar00rootroot00000000000000#include "./util.h" #include #include #include StrVal::StrVal(const v8::Local &arg) : data(NULL), size(0), isBuffer(false) { if (node::Buffer::HasInstance(arg)) { isBuffer = true; size = length = node::Buffer::Length(arg); data = node::Buffer::Data(arg); } else { auto t = arg->ToString(Nan::GetCurrentContext()); if (!t.IsEmpty()) { auto s = t.ToLocalChecked(); length = Nan::DecodeBytes(s); size = Nan::DecodeBytes(s, Nan::UTF8); buffer.resize(size + 1); data = &buffer[0]; Nan::DecodeWrite(data, size, s, Nan::UTF8); buffer[size] = '\0'; } } } void consoleCall(const v8::Local &methodName, v8::Local text) { auto context = Nan::GetCurrentContext(); auto maybeConsole = bind( Nan::Get(context->Global(), Nan::New("console").ToLocalChecked()), [context](v8::Local console) { return console->ToObject(context); }); if (maybeConsole.IsEmpty()) return; auto console = maybeConsole.ToLocalChecked(); auto maybeMethod = bind( Nan::Get(console, methodName), [context](v8::Local method) { return method->ToObject(context); }); if (maybeMethod.IsEmpty()) return; auto method = maybeMethod.ToLocalChecked(); if (!method->IsFunction()) return; Nan::CallAsFunction(method, console, 1, &text); } void printDeprecationWarning(const char *warning) { std::string prefixedWarning = "DeprecationWarning: "; prefixedWarning += warning; consoleCall(Nan::New("error").ToLocalChecked(), Nan::New(prefixedWarning).ToLocalChecked()); } v8::Local callToString(const v8::Local &object) { auto context = Nan::GetCurrentContext(); auto maybeMethod = bind( Nan::Get(object, Nan::New("toString").ToLocalChecked()), [context](v8::Local method) { return method->ToObject(context); }); if (maybeMethod.IsEmpty()) return Nan::New("No toString() is found").ToLocalChecked(); auto method = maybeMethod.ToLocalChecked(); if (!method->IsFunction()) return Nan::New("No toString() is found").ToLocalChecked(); auto maybeResult = Nan::CallAsFunction(method, object, 0, nullptr); if (maybeResult.IsEmpty()) { return Nan::New("nothing was returned").ToLocalChecked(); } auto result = maybeResult.ToLocalChecked(); if (result->IsObject()) { return callToString(result->ToObject(context).ToLocalChecked()); } Nan::Utf8String val(result->ToString(context).ToLocalChecked()); return Nan::New(std::string(*val, val.length())).ToLocalChecked(); } node-re2-1.20.12/lib/util.h000066400000000000000000000014101462511572500151700ustar00rootroot00000000000000#ifndef UTIL_H_ #define UTIL_H_ #include "./wrapped_re2.h" #include struct StrVal { std::vector buffer; char *data; size_t size, length; bool isBuffer; StrVal() : data(NULL), size(0), length(0), isBuffer(false) {} StrVal(const v8::Local &arg); operator re2::StringPiece() const { return re2::StringPiece(data, size); } }; template inline v8::MaybeLocal bind(v8::MaybeLocal

param, L lambda) { return param.IsEmpty() ? v8::MaybeLocal() : lambda(param.ToLocalChecked()); } void consoleCall(const v8::Local &methodName, v8::Local text); void printDeprecationWarning(const char *warning); v8::Local callToString(const v8::Local &object); #endif node-re2-1.20.12/lib/wrapped_re2.h000066400000000000000000000056151462511572500164400ustar00rootroot00000000000000#ifndef WRAPPED_RE2_H_ #define WRAPPED_RE2_H_ #include #include #include class WrappedRE2 : public Nan::ObjectWrap { private: WrappedRE2(const re2::StringPiece &pattern, const re2::RE2::Options &options, const std::string &src, const bool &g, const bool &i, const bool &m, const bool &s, const bool &y, const bool &d) : regexp(pattern, options), source(src), global(g), ignoreCase(i), multiline(m), dotAll(s), sticky(y), hasIndices(d), lastIndex(0) {} static NAN_METHOD(New); static NAN_METHOD(ToString); static NAN_GETTER(GetSource); static NAN_GETTER(GetFlags); static NAN_GETTER(GetGlobal); static NAN_GETTER(GetIgnoreCase); static NAN_GETTER(GetMultiline); static NAN_GETTER(GetDotAll); static NAN_GETTER(GetUnicode); static NAN_GETTER(GetSticky); static NAN_GETTER(GetHasIndices); static NAN_GETTER(GetLastIndex); static NAN_SETTER(SetLastIndex); static NAN_GETTER(GetInternalSource); // RegExp methods static NAN_METHOD(Exec); static NAN_METHOD(Test); // String methods static NAN_METHOD(Match); static NAN_METHOD(Replace); static NAN_METHOD(Search); static NAN_METHOD(Split); // strict Unicode warning support static NAN_GETTER(GetUnicodeWarningLevel); static NAN_SETTER(SetUnicodeWarningLevel); public: static v8::Local Init(); static inline bool HasInstance(v8::Local object) { auto isolate = v8::Isolate::GetCurrent(); auto p_tpl = Nan::GetIsolateData>(isolate); return p_tpl->Get(isolate)->HasInstance(object); } enum UnicodeWarningLevels { NOTHING, WARN_ONCE, WARN, THROW }; static UnicodeWarningLevels unicodeWarningLevel; static bool alreadyWarnedAboutUnicode; re2::RE2 regexp; std::string source; bool global; bool ignoreCase; bool multiline; bool dotAll; bool sticky; bool hasIndices; size_t lastIndex; }; // utilities inline size_t getUtf8Length(const uint16_t *from, const uint16_t *to) { size_t n = 0; while (from != to) { uint16_t ch = *from++; if (ch <= 0x7F) ++n; else if (ch <= 0x7FF) n += 2; else if (0xD800 <= ch && ch <= 0xDFFF) { n += 4; if (from == to) break; ++from; } else if (ch < 0xFFFF) n += 3; else n += 4; } return n; } inline size_t getUtf16Length(const char *from, const char *to) { size_t n = 0; while (from != to) { unsigned ch = *from & 0xFF; if (ch < 0xF0) { if (ch < 0x80) { ++from; } else { if (ch < 0xE0) { from += 2; if (from == to + 1) { ++n; break; } } else { from += 3; if (from > to && from < to + 3) { ++n; break; } } } ++n; } else { from += 4; n += 2; if (from > to && from < to + 4) break; } } return n; } inline size_t getUtf8CharSize(char ch) { return ((0xE5000000 >> ((ch >> 3) & 0x1E)) & 3) + 1; } #endif node-re2-1.20.12/package-lock.json000066400000000000000000001245051462511572500165230ustar00rootroot00000000000000{ "name": "re2", "version": "1.20.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "re2", "version": "1.20.12", "hasInstallScript": true, "license": "BSD-3-Clause", "dependencies": { "install-artifact-from-github": "^1.3.5", "nan": "^2.19.0", "node-gyp": "^10.1.0" }, "devDependencies": { "@types/node": "^20.12.12", "heya-unit": "^0.3.0", "typescript": "^5.4.5" } }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", "strip-ansi": "^7.0.1", "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", "wrap-ansi": "^8.1.0", "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" }, "engines": { "node": ">=12" } }, "node_modules/@npmcli/agent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@npmcli/agent/-/agent-2.2.0.tgz", "integrity": "sha512-2yThA1Es98orMkpSLVqlDZAMPK3jHJhifP2gnNUdk1754uZ8yI5c+ulCoVG+WlntQA6MzhrURMXjSd9Z7dJ2/Q==", "dependencies": { "agent-base": "^7.1.0", "http-proxy-agent": "^7.0.0", "https-proxy-agent": "^7.0.1", "lru-cache": "^10.0.1", "socks-proxy-agent": "^8.0.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@npmcli/fs": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-3.1.0.tgz", "integrity": "sha512-7kZUAaLscfgbwBQRbvdMYaZOWyMEcPTH/tJjnyAWJ/dvvs9Ef+CERx/qJb9GExJpl1qipaDGn7KqHnFGGixd0w==", "dependencies": { "semver": "^7.3.5" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", "optional": true, "engines": { "node": ">=14" } }, "node_modules/@types/node": { "version": "20.12.12", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", "dev": true, "dependencies": { "undici-types": "~5.26.4" } }, "node_modules/abbrev": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-2.0.0.tgz", "integrity": "sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==", "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/agent-base": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", "dependencies": { "debug": "^4.3.4" }, "engines": { "node": ">= 14" } }, "node_modules/aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", "dependencies": { "clean-stack": "^2.0.0", "indent-string": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/ansi-styles": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/cacache": { "version": "18.0.0", "resolved": "https://registry.npmjs.org/cacache/-/cacache-18.0.0.tgz", "integrity": "sha512-I7mVOPl3PUCeRub1U8YoGz2Lqv9WOBpobZ8RyWFXmReuILz+3OAyTa5oH3QPdtKZD7N0Yk00aLfzn0qvp8dZ1w==", "dependencies": { "@npmcli/fs": "^3.1.0", "fs-minipass": "^3.0.0", "glob": "^10.2.2", "lru-cache": "^10.0.1", "minipass": "^7.0.3", "minipass-collect": "^1.0.2", "minipass-flush": "^1.0.5", "minipass-pipeline": "^1.2.4", "p-map": "^4.0.0", "ssri": "^10.0.0", "tar": "^6.1.11", "unique-filename": "^3.0.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", "engines": { "node": ">=10" } }, "node_modules/clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", "engines": { "node": ">=6" } }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dependencies": { "color-name": "~1.1.4" }, "engines": { "node": ">=7.0.0" } }, "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" }, "engines": { "node": ">= 8" } }, "node_modules/cross-spawn/node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, "node_modules/cross-spawn/node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "bin/node-which" }, "engines": { "node": ">= 8" } }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { "ms": "2.1.2" }, "engines": { "node": ">=6.0" }, "peerDependenciesMeta": { "supports-color": { "optional": true } } }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" }, "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" }, "node_modules/encoding": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", "optional": true, "dependencies": { "iconv-lite": "^0.6.2" } }, "node_modules/env-paths": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", "engines": { "node": ">=6" } }, "node_modules/err-code": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==" }, "node_modules/exponential-backoff": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz", "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==" }, "node_modules/foreground-child": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" }, "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/fs-minipass": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-3.0.3.tgz", "integrity": "sha512-XUBA9XClHbnJWSfBzjkm6RvPsyg3sryZt06BEQoXcF7EK/xpGaQYJgQKDJSUH5SGZ76Y7pFx1QBnXz09rU5Fbw==", "dependencies": { "minipass": "^7.0.3" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/glob": { "version": "10.3.10", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^2.3.5", "minimatch": "^9.0.1", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", "path-scurry": "^1.10.1" }, "bin": { "glob": "dist/esm/bin.mjs" }, "engines": { "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/graceful-fs": { "version": "4.2.10", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" }, "node_modules/heya-ice": { "version": "0.1.11", "resolved": "https://registry.npmjs.org/heya-ice/-/heya-ice-0.1.11.tgz", "integrity": "sha512-PpYDXpPwENe+WnznoSAfDrd9ltNyRIfa60aJUj582yzUEq5OZID50n0Y7pQ+YQbB/CgmrPM74QAViztsvcfqWA==", "dev": true }, "node_modules/heya-unify": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/heya-unify/-/heya-unify-0.2.7.tgz", "integrity": "sha512-d/4NacYl52tt4ofbP7gz+YmbjLrI2jkrRxSSd1a26yXfRS1vQxmZkZ6L+O1xUsgDSwx4HCDWR5U+ZFykdoHVig==", "dev": true, "dependencies": { "heya-ice": "^0.1.11" } }, "node_modules/heya-unit": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/heya-unit/-/heya-unit-0.3.0.tgz", "integrity": "sha512-M3SWtAr+21On/5AsonvvRYeeJUS8bxBhR8WaQ9aAtZzT3quizlR6KuHq1tkPSNFUX7TSkflzOjVi1dWbfYXKQg==", "dev": true, "dependencies": { "heya-ice": ">=0.1", "heya-unify": ">=0.2" } }, "node_modules/http-cache-semantics": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==" }, "node_modules/http-proxy-agent": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", "dependencies": { "agent-base": "^7.1.0", "debug": "^4.3.4" }, "engines": { "node": ">= 14" } }, "node_modules/https-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.2.tgz", "integrity": "sha512-NmLNjm6ucYwtcUmL7JQC1ZQ57LmHP4lT15FQ8D61nak1rO6DH+fz5qNK2Ap5UN4ZapYICE3/0KodcLYSPsPbaA==", "dependencies": { "agent-base": "^7.0.2", "debug": "4" }, "engines": { "node": ">= 14" } }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", "optional": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" }, "engines": { "node": ">=0.10.0" } }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "engines": { "node": ">=0.8.19" } }, "node_modules/indent-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", "engines": { "node": ">=8" } }, "node_modules/install-artifact-from-github": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/install-artifact-from-github/-/install-artifact-from-github-1.3.5.tgz", "integrity": "sha512-gZHC7f/cJgXz7MXlHFBxPVMsvIbev1OQN1uKQYKVJDydGNm9oYf9JstbU4Atnh/eSvk41WtEovoRm+8IF686xg==", "bin": { "install-from-cache": "bin/install-from-cache.js", "save-to-github-cache": "bin/save-to-github-cache.js" } }, "node_modules/ip": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==" }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "engines": { "node": ">=8" } }, "node_modules/is-lambda": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==" }, "node_modules/isexe": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", "engines": { "node": ">=16" } }, "node_modules/jackspeak": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", "dependencies": { "@isaacs/cliui": "^8.0.2" }, "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" }, "optionalDependencies": { "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/lru-cache": { "version": "10.0.2", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.2.tgz", "integrity": "sha512-Yj9mA8fPiVgOUpByoTZO5pNrcl5Yk37FcSHsUINpAsaBIEZIuqcCclDZJCVxqQShDsmYX8QG63svJiTbOATZwg==", "dependencies": { "semver": "^7.3.5" }, "engines": { "node": "14 || >=16.14" } }, "node_modules/make-fetch-happen": { "version": "13.0.0", "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-13.0.0.tgz", "integrity": "sha512-7ThobcL8brtGo9CavByQrQi+23aIfgYU++wg4B87AIS8Rb2ZBt/MEaDqzA00Xwv/jUjAjYkLHjVolYuTLKda2A==", "dependencies": { "@npmcli/agent": "^2.0.0", "cacache": "^18.0.0", "http-cache-semantics": "^4.1.1", "is-lambda": "^1.0.1", "minipass": "^7.0.2", "minipass-fetch": "^3.0.0", "minipass-flush": "^1.0.5", "minipass-pipeline": "^1.2.4", "negotiator": "^0.6.3", "promise-retry": "^2.0.1", "ssri": "^10.0.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/minimatch": { "version": "9.0.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/minipass": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", "engines": { "node": ">=16 || 14 >=14.17" } }, "node_modules/minipass-collect": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/minipass-collect/-/minipass-collect-1.0.2.tgz", "integrity": "sha512-6T6lH0H8OG9kITm/Jm6tdooIbogG9e0tLgpY6mphXSm/A9u8Nq1ryBG+Qspiub9LjWlBPsPS3tWQ/Botq4FdxA==", "dependencies": { "minipass": "^3.0.0" }, "engines": { "node": ">= 8" } }, "node_modules/minipass-collect/node_modules/minipass": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dependencies": { "yallist": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/minipass-fetch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-3.0.4.tgz", "integrity": "sha512-jHAqnA728uUpIaFm7NWsCnqKT6UqZz7GcI/bDpPATuwYyKwJwW0remxSCxUlKiEty+eopHGa3oc8WxgQ1FFJqg==", "dependencies": { "minipass": "^7.0.3", "minipass-sized": "^1.0.3", "minizlib": "^2.1.2" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" }, "optionalDependencies": { "encoding": "^0.1.13" } }, "node_modules/minipass-flush": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/minipass-flush/-/minipass-flush-1.0.5.tgz", "integrity": "sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==", "dependencies": { "minipass": "^3.0.0" }, "engines": { "node": ">= 8" } }, "node_modules/minipass-flush/node_modules/minipass": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dependencies": { "yallist": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/minipass-pipeline": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz", "integrity": "sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==", "dependencies": { "minipass": "^3.0.0" }, "engines": { "node": ">=8" } }, "node_modules/minipass-pipeline/node_modules/minipass": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dependencies": { "yallist": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/minipass-sized": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/minipass-sized/-/minipass-sized-1.0.3.tgz", "integrity": "sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==", "dependencies": { "minipass": "^3.0.0" }, "engines": { "node": ">=8" } }, "node_modules/minipass-sized/node_modules/minipass": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dependencies": { "yallist": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/minizlib": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", "dependencies": { "minipass": "^3.0.0", "yallist": "^4.0.0" }, "engines": { "node": ">= 8" } }, "node_modules/minizlib/node_modules/minipass": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dependencies": { "yallist": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", "bin": { "mkdirp": "bin/cmd.js" }, "engines": { "node": ">=10" } }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/nan": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.19.0.tgz", "integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==" }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "engines": { "node": ">= 0.6" } }, "node_modules/node-gyp": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-10.1.0.tgz", "integrity": "sha512-B4J5M1cABxPc5PwfjhbV5hoy2DP9p8lFXASnEN6hugXOa61416tnTZ29x9sSwAd0o99XNIcpvDDy1swAExsVKA==", "dependencies": { "env-paths": "^2.2.0", "exponential-backoff": "^3.1.1", "glob": "^10.3.10", "graceful-fs": "^4.2.6", "make-fetch-happen": "^13.0.0", "nopt": "^7.0.0", "proc-log": "^3.0.0", "semver": "^7.3.5", "tar": "^6.1.2", "which": "^4.0.0" }, "bin": { "node-gyp": "bin/node-gyp.js" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/nopt": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/nopt/-/nopt-7.2.0.tgz", "integrity": "sha512-CVDtwCdhYIvnAzFoJ6NJ6dX3oga9/HyciQDnG1vQDjSLMeKLJ4A93ZqYKDrgYSr1FBY5/hMYC+2VCi24pgpkGA==", "dependencies": { "abbrev": "^2.0.0" }, "bin": { "nopt": "bin/nopt.js" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/p-map": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", "dependencies": { "aggregate-error": "^3.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "engines": { "node": ">=8" } }, "node_modules/path-scurry": { "version": "1.10.1", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", "dependencies": { "lru-cache": "^9.1.1 || ^10.0.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/proc-log": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-3.0.0.tgz", "integrity": "sha512-++Vn7NS4Xf9NacaU9Xq3URUuqZETPsf8L4j5/ckhaRYsfPeRyzGw+iDjFhV/Jr3uNmTvvddEJFWh5R1gRgUH8A==", "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/promise-retry": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", "dependencies": { "err-code": "^2.0.2", "retry": "^0.12.0" }, "engines": { "node": ">=10" } }, "node_modules/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", "engines": { "node": ">= 4" } }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "optional": true }, "node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dependencies": { "lru-cache": "^6.0.0" }, "bin": { "semver": "bin/semver.js" }, "engines": { "node": ">=10" } }, "node_modules/semver/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dependencies": { "yallist": "^4.0.0" }, "engines": { "node": ">=10" } }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dependencies": { "shebang-regex": "^3.0.0" }, "engines": { "node": ">=8" } }, "node_modules/shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "engines": { "node": ">=8" } }, "node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "engines": { "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", "engines": { "node": ">= 6.0.0", "npm": ">= 3.0.0" } }, "node_modules/socks": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", "dependencies": { "ip": "^2.0.0", "smart-buffer": "^4.2.0" }, "engines": { "node": ">= 10.13.0", "npm": ">= 3.0.0" } }, "node_modules/socks-proxy-agent": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.2.tgz", "integrity": "sha512-8zuqoLv1aP/66PHF5TqwJ7Czm3Yv32urJQHrVyhD7mmA6d61Zv8cIXQYPTWwmg6qlupnPvs/QKDmfa4P/qct2g==", "dependencies": { "agent-base": "^7.0.2", "debug": "^4.3.4", "socks": "^2.7.1" }, "engines": { "node": ">= 14" } }, "node_modules/ssri": { "version": "10.0.5", "resolved": "https://registry.npmjs.org/ssri/-/ssri-10.0.5.tgz", "integrity": "sha512-bSf16tAFkGeRlUNDjXu8FzaMQt6g2HZJrun7mtMbIPOddxt3GLMSz5VWUWcqTJUPfLEaDIepGxv+bYQW49596A==", "dependencies": { "minipass": "^7.0.3" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/string-width-cjs": { "name": "string-width", "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/string-width-cjs/node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "engines": { "node": ">=8" } }, "node_modules/string-width-cjs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "node_modules/string-width-cjs/node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dependencies": { "ansi-regex": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dependencies": { "ansi-regex": "^6.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/strip-ansi-cjs": { "name": "strip-ansi", "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dependencies": { "ansi-regex": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "engines": { "node": ">=8" } }, "node_modules/tar": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" }, "engines": { "node": ">=10" } }, "node_modules/tar/node_modules/fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", "dependencies": { "minipass": "^3.0.0" }, "engines": { "node": ">= 8" } }, "node_modules/tar/node_modules/fs-minipass/node_modules/minipass": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dependencies": { "yallist": "^4.0.0" }, "engines": { "node": ">=8" } }, "node_modules/tar/node_modules/minipass": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "engines": { "node": ">=8" } }, "node_modules/typescript": { "version": "5.4.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { "node": ">=14.17" } }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, "node_modules/unique-filename": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-3.0.0.tgz", "integrity": "sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==", "dependencies": { "unique-slug": "^4.0.0" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/unique-slug": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-4.0.0.tgz", "integrity": "sha512-WrcA6AyEfqDX5bWige/4NQfPZMtASNVxdmWR76WESYQVAACSgWcR6e9i0mofqqBxYFtL4oAxPIptY73/0YE1DQ==", "dependencies": { "imurmurhash": "^0.1.4" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/which": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", "dependencies": { "isexe": "^3.1.1" }, "bin": { "node-which": "bin/which.js" }, "engines": { "node": "^16.13.0 || >=18.0.0" } }, "node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", "strip-ansi": "^7.0.1" }, "engines": { "node": ">=12" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, "engines": { "node": ">=10" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "engines": { "node": ">=8" } }, "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dependencies": { "color-convert": "^2.0.1" }, "engines": { "node": ">=8" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "node_modules/wrap-ansi-cjs/node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" }, "engines": { "node": ">=8" } }, "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dependencies": { "ansi-regex": "^5.0.1" }, "engines": { "node": ">=8" } }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" } } } node-re2-1.20.12/package.json000066400000000000000000000026301462511572500155670ustar00rootroot00000000000000{ "name": "re2", "version": "1.20.12", "description": "Bindings for RE2: fast, safe alternative to backtracking regular expression engines.", "homepage": "https://github.com/uhop/node-re2", "bugs": "https://github.com/uhop/node-re2/issues", "type": "commonjs", "main": "re2.js", "types": "re2.d.ts", "files": [ "binding.gyp", "lib", "re2.d.ts", "scripts/*.js", "vendor" ], "dependencies": { "install-artifact-from-github": "^1.3.5", "nan": "^2.19.0", "node-gyp": "^10.1.0" }, "devDependencies": { "@types/node": "^20.12.12", "heya-unit": "^0.3.0", "typescript": "^5.4.5" }, "scripts": { "test": "node tests/tests.js", "ts-test": "tsc", "save-to-github": "save-to-github-cache --artifact build/Release/re2.node", "install": "install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || node-gyp rebuild", "verify-build": "node scripts/verify-build.js", "rebuild": "node-gyp rebuild" }, "github": "https://github.com/uhop/node-re2", "repository": { "type": "git", "url": "git://github.com/uhop/node-re2.git" }, "keywords": [ "RegExp", "RegEx", "text processing", "PCRE alternative" ], "author": "Eugene Lazutkin (https://lazutkin.com/)", "license": "BSD-3-Clause" } node-re2-1.20.12/re2.d.ts000066400000000000000000000026131462511572500145640ustar00rootroot00000000000000declare module 're2' { interface RE2BufferExecArray { index: number; input: Buffer; 0: Buffer; groups?: { [key: string]: Buffer } } interface RE2BufferMatchArray { index?: number; input?: Buffer; 0: Buffer; groups?: { [key: string]: Buffer } } interface RE2 extends RegExp { exec(str: string): RegExpExecArray | null; exec(str: Buffer): RE2BufferExecArray | null; match(str: string): RegExpMatchArray | null; match(str: Buffer): RE2BufferMatchArray | null; test(str: string | Buffer): boolean; replace(str: K, replaceValue: string | Buffer): K; replace(str: K, replacer: (substring: string, ...args: any[]) => string | Buffer): K; search(str: string | Buffer): number; split(str: K, limit?: number): K[]; } interface RE2Constructor extends RegExpConstructor { new(pattern: Buffer | RegExp | RE2 | string): RE2; new(pattern: Buffer | string, flags?: string | Buffer): RE2; (pattern: Buffer | RegExp | RE2 | string): RE2; (pattern: Buffer | string, flags?: string | Buffer): RE2; readonly prototype: RE2; unicodeWarningLevel: 'nothing' | 'warnOnce' | 'warn' | 'throw'; getUtf8Length(value: string): number; getUtf16Length(value: Buffer): number; } var RE2: RE2Constructor; export = RE2; } node-re2-1.20.12/re2.js000066400000000000000000000020071462511572500143250ustar00rootroot00000000000000'use strict'; const RE2 = require('./build/Release/re2.node'); if (typeof Symbol != 'undefined') { Symbol.match && (RE2.prototype[Symbol.match] = function (str) { return this.match(str); }); Symbol.search && (RE2.prototype[Symbol.search] = function (str) { return this.search(str); }); Symbol.replace && (RE2.prototype[Symbol.replace] = function (str, repl) { return this.replace(str, repl); }); Symbol.split && (RE2.prototype[Symbol.split] = function (str, limit) { return this.split(str, limit); }); Symbol.matchAll && (RE2.prototype[Symbol.matchAll] = function* (str) { if (!this.global) { throw TypeError('String.prototype.matchAll called with a non-global RE2 argument'); } const re = new RE2(this); re.lastIndex = this.lastIndex; for (;;) { const result = re.exec(str); if (!result) break; if (result[0] === '') ++re.lastIndex; yield result; } }); } module.exports = RE2; node-re2-1.20.12/scripts/000077500000000000000000000000001462511572500147675ustar00rootroot00000000000000node-re2-1.20.12/scripts/verify-build.js000066400000000000000000000005451462511572500177320ustar00rootroot00000000000000'use strict'; // This is a light-weight script to make sure that the package works. const assert = require('assert').strict; const RE2 = require("../re2"); const sample = "abbcdefabh"; const re1 = new RE2("ab*", "g"); assert(re1.test(sample)); const re2 = RE2("ab*"); assert(re2.test(sample)); const re3 = new RE2("abc"); assert(!re3.test(sample)); node-re2-1.20.12/tests/000077500000000000000000000000001462511572500144425ustar00rootroot00000000000000node-re2-1.20.12/tests/test_exec.js000066400000000000000000000305551462511572500167730ustar00rootroot00000000000000'use strict'; var unit = require('heya-unit'); var RE2 = require('../re2'); // tests unit.add(module, [ // These tests are copied from MDN: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec function test_execBasic(t) { 'use strict'; var re = new RE2('quick\\s(brown).+?(jumps)', 'ig'); eval(t.TEST("re.source === 'quick\\\\s(brown).+?(jumps)'")); eval(t.TEST('re.ignoreCase')); eval(t.TEST('re.global')); eval(t.TEST('!re.multiline')); var result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog'); eval( t.TEST("t.unify(result, ['Quick Brown Fox Jumps', 'Brown', 'Jumps'])") ); eval(t.TEST('result.index === 4')); eval( t.TEST("result.input === 'The Quick Brown Fox Jumps Over The Lazy Dog'") ); eval(t.TEST('re.lastIndex === 25')); }, function test_execSucc(t) { 'use strict'; var str = 'abbcdefabh'; var re = new RE2('ab*', 'g'); var result = re.exec(str); eval(t.TEST('!!result')); eval(t.TEST("result[0] === 'abb'")); eval(t.TEST('result.index === 0')); eval(t.TEST('re.lastIndex === 3')); result = re.exec(str); eval(t.TEST('!!result')); eval(t.TEST("result[0] === 'ab'")); eval(t.TEST('result.index === 7')); eval(t.TEST('re.lastIndex === 9')); result = re.exec(str); eval(t.TEST('!result')); }, function test_execSimple(t) { 'use strict'; var re = new RE2('(hello \\S+)'); var result = re.exec('This is a hello world!'); eval(t.TEST("result[1] === 'hello world!'")); }, function test_execFail(t) { 'use strict'; var re = new RE2('(a+)?(b+)?'); var result = re.exec('aaabb'); eval(t.TEST("result[1] === 'aaa'")); eval(t.TEST("result[2] === 'bb'")); result = re.exec('aaacbb'); eval(t.TEST("result[1] === 'aaa'")); eval(t.TEST('result[2] === undefined')); eval(t.TEST('result.length === 3')); }, function test_execAnchoredToBeginning(t) { 'use strict'; var re = RE2('^hello', 'g'); var result = re.exec('hellohello'); eval(t.TEST("t.unify(result, ['hello'])")); eval(t.TEST('result.index === 0')); eval(t.TEST('re.lastIndex === 5')); eval(t.TEST("re.exec('hellohello') === null")); }, function test_execInvalid(t) { 'use strict'; var re = RE2(''); try { re.exec({ toString() { throw 'corner'; } }); t.test(false); // shouldn't be here } catch (e) { eval(t.TEST("e === 'corner'")); } }, function test_execAnchor1(t) { 'use strict'; var re = new RE2('b|^a', 'g'); var result = re.exec('aabc'); eval(t.TEST('!!result')); eval(t.TEST('result.index === 0')); eval(t.TEST('re.lastIndex === 1')); result = re.exec('aabc'); eval(t.TEST('!!result')); eval(t.TEST('result.index === 2')); eval(t.TEST('re.lastIndex === 3')); result = re.exec('aabc'); eval(t.TEST('!result')); }, function test_execAnchor2(t) { 'use strict'; var re = new RE2('(?:^a)', 'g'); var result = re.exec('aabc'); eval(t.TEST('!!result')); eval(t.TEST('result.index === 0')); eval(t.TEST('re.lastIndex === 1')); result = re.exec('aabc'); eval(t.TEST('!result')); }, // Unicode tests function test_execUnicode(t) { 'use strict'; var re = new RE2('охотник\\s(желает).+?(где)', 'ig'); eval(t.TEST("re.source === 'охотник\\\\s(желает).+?(где)'")); eval(t.TEST('re.ignoreCase')); eval(t.TEST('re.global')); eval(t.TEST('!re.multiline')); var result = re.exec('Каждый Охотник Желает Знать Где Сидит Фазан'); eval( t.TEST("t.unify(result, ['Охотник Желает Знать Где', 'Желает', 'Где'])") ); eval(t.TEST('result.index === 7')); eval( t.TEST("result.input === 'Каждый Охотник Желает Знать Где Сидит Фазан'") ); eval(t.TEST('re.lastIndex === 31')); eval( t.TEST( "result.input.substr(result.index) === 'Охотник Желает Знать Где Сидит Фазан'" ) ); eval(t.TEST("result.input.substr(re.lastIndex) === ' Сидит Фазан'")); }, function test_execUnicodeSubsequent(t) { 'use strict'; var str = 'аббвгдеабё'; var re = new RE2('аб*', 'g'); var result = re.exec(str); eval(t.TEST('!!result')); eval(t.TEST("result[0] === 'абб'")); eval(t.TEST('result.index === 0')); eval(t.TEST('re.lastIndex === 3')); result = re.exec(str); eval(t.TEST('!!result')); eval(t.TEST("result[0] === 'аб'")); eval(t.TEST('result.index === 7')); eval(t.TEST('re.lastIndex === 9')); result = re.exec(str); eval(t.TEST('!result')); }, function test_execUnicodeSupplementary(t) { 'use strict'; var re = new RE2('\\u{1F603}', 'g'); eval(t.TEST("re.source === '\\\\u{1F603}'")); eval(t.TEST("re.internalSource === '\\\\x{1F603}'")); eval(t.TEST('!re.ignoreCase')); eval(t.TEST('re.global')); eval(t.TEST('!re.multiline')); var result = re.exec('\u{1F603}'); // 1F603 is the SMILING FACE WITH OPEN MOUTH emoji eval(t.TEST("t.unify(result, ['\\u{1F603}'])")); eval(t.TEST('result.index === 0')); eval(t.TEST("result.input === '\\u{1F603}'")); eval(t.TEST('re.lastIndex === 2')); var re2 = new RE2('.', 'g'); eval(t.TEST("re2.source === '.'")); eval(t.TEST('!re2.ignoreCase')); eval(t.TEST('re2.global')); eval(t.TEST('!re2.multiline')); var result2 = re2.exec('\u{1F603}'); eval(t.TEST("t.unify(result2, ['\\u{1F603}'])")); eval(t.TEST('result2.index === 0')); eval(t.TEST("result2.input === '\\u{1F603}'")); eval(t.TEST('re2.lastIndex === 2')); var re3 = new RE2('[\u{1F603}-\u{1F605}]', 'g'); eval(t.TEST("re3.source === '[\u{1F603}-\u{1F605}]'")); eval(t.TEST('!re3.ignoreCase')); eval(t.TEST('re3.global')); eval(t.TEST('!re3.multiline')); var result3 = re3.exec('\u{1F604}'); eval(t.TEST("t.unify(result3, ['\\u{1F604}'])")); eval(t.TEST('result3.index === 0')); eval(t.TEST("result3.input === '\\u{1F604}'")); eval(t.TEST('re3.lastIndex === 2')); }, // Buffer tests function test_execBuffer(t) { 'use strict'; var re = new RE2('охотник\\s(желает).+?(где)', 'ig'); var buf = new Buffer('Каждый Охотник Желает Знать Где Сидит Фазан'); var result = re.exec(buf); eval(t.TEST('result.length === 3')); eval(t.TEST('result[0] instanceof Buffer')); eval(t.TEST('result[1] instanceof Buffer')); eval(t.TEST('result[2] instanceof Buffer')); eval(t.TEST("result[0].toString() === 'Охотник Желает Знать Где'")); eval(t.TEST("result[1].toString() === 'Желает'")); eval(t.TEST("result[2].toString() === 'Где'")); eval(t.TEST('result.index === 13')); eval(t.TEST('result.input instanceof Buffer')); eval( t.TEST( "result.input.toString() === 'Каждый Охотник Желает Знать Где Сидит Фазан'" ) ); eval(t.TEST('re.lastIndex === 58')); eval( t.TEST( "result.input.toString('utf8', result.index) === 'Охотник Желает Знать Где Сидит Фазан'" ) ); eval( t.TEST("result.input.toString('utf8', re.lastIndex) === ' Сидит Фазан'") ); }, // Sticky tests function test_execSticky(t) { 'use strict'; var re = new RE2('\\s+', 'y'); eval(t.TEST("re.exec('Hello world, how are you?') === null")); re.lastIndex = 5; var result = re.exec('Hello world, how are you?'); eval(t.TEST("t.unify(result, [' '])")); eval(t.TEST('result.index === 5')); eval(t.TEST('re.lastIndex === 6')); var re2 = new RE2('\\s+', 'gy'); eval(t.TEST("re2.exec('Hello world, how are you?') === null")); re2.lastIndex = 5; var result2 = re2.exec('Hello world, how are you?'); eval(t.TEST("t.unify(result2, [' '])")); eval(t.TEST('result2.index === 5')); eval(t.TEST('re2.lastIndex === 6')); }, function test_execSupplemental(t) { 'use strict'; var re = new RE2('\\w+', 'g'); var testString = '🤡🤡🤡 Hello clown world!'; var result = re.exec(testString); eval(t.TEST("t.unify(result, ['Hello'])")); result = re.exec(testString); eval(t.TEST("t.unify(result, ['clown'])")); result = re.exec(testString); eval(t.TEST("t.unify(result, ['world'])")); }, // Multiline test function test_execMultiline(t) { 'use strict'; const re = new RE2('^xy', 'm'), pattern = ` xy1 xy2 (at start of line) xy3`; const result = re.exec(pattern); eval(t.TEST('!!result')); eval(t.TEST("result[0] === 'xy'")); eval(t.TEST('result.index > 3')); eval(t.TEST('result.index < pattern.length - 4')); eval( t.TEST('result[0] === pattern.substr(result.index, result[0].length)') ); }, // dotAll tests function test_execDotAll(t) { 'use strict'; eval(t.TEST("new RE2('a.c').test('abc')")); eval(t.TEST("new RE2(/a.c/).test('a c')")); eval(t.TEST("!new RE2(/a.c/).test('a\\nc')")); eval(t.TEST("new RE2('a.c', 's').test('abc')")); eval(t.TEST("new RE2(/a.c/s).test('a c')")); eval(t.TEST("new RE2(/a.c/s).test('a\\nc')")); }, // hasIndices tests function test_execHasIndices(t) { 'use strict'; eval(t.TEST("!new RE2('1').hasIndices")); eval(t.TEST('!new RE2(/1/).hasIndices')); var re = new RE2('(aa)(?b)?(?ccc)', 'd'); eval(t.TEST('re.hasIndices')); var result = re.exec('1aabccc2'); eval(t.TEST('result.length === 4')); eval(t.TEST("result.input === '1aabccc2'")); eval(t.TEST('result.index === 1')); eval(t.TEST('Object.keys(result.groups).length === 2')); eval(t.TEST("result.groups.b === 'b'")); eval(t.TEST("result.groups.c === 'ccc'")); eval(t.TEST("result[0] === 'aabccc'")); eval(t.TEST("result[1] === 'aa'")); eval(t.TEST("result[2] === 'b'")); eval(t.TEST("result[3] === 'ccc'")); eval(t.TEST('result.indices.length === 4')); eval(t.TEST('t.unify(result.indices, [[1, 7], [1, 3], [3, 4], [4, 7]])')); eval(t.TEST('Object.keys(result.indices.groups).length === 2')); eval(t.TEST('t.unify(result.indices.groups.b, [3, 4])')); eval(t.TEST('t.unify(result.indices.groups.c, [4, 7])')); result = re.exec('1aaccc2'); eval(t.TEST('result.length === 4')); eval(t.TEST("result.input === '1aaccc2'")); eval(t.TEST('result.index === 1')); eval(t.TEST('Object.keys(result.groups).length === 2')); eval(t.TEST('result.groups.b === undefined')); eval(t.TEST("result.groups.c === 'ccc'")); eval(t.TEST("result[0] === 'aaccc'")); eval(t.TEST("result[1] === 'aa'")); eval(t.TEST('result[2] === undefined')); eval(t.TEST("result[3] === 'ccc'")); eval(t.TEST('result.indices.length === 4')); eval( t.TEST('t.unify(result.indices, [[1, 6], [1, 3], undefined, [3, 6]])') ); eval(t.TEST('Object.keys(result.indices.groups).length === 2')); eval(t.TEST('t.unify(result.indices.groups.b, undefined)')); eval(t.TEST('t.unify(result.indices.groups.c, [3, 6])')); try { re = new RE2(new RegExp('1', 'd')); eval(t.TEST('re.hasIndices')); } catch (e) { // squelch } }, function test_hasIndexLastIndex(t) { 'use strict'; const re2 = new RE2('a', 'dg'); eval(t.TEST('re2.lastIndex === 0')); let result = re2.exec('abca'); eval(t.TEST('re2.lastIndex === 1')); eval(t.TEST('result.index === 0')); eval(t.TEST('t.unify(result.indices, [[0, 1]])')); result = re2.exec('abca'); eval(t.TEST('re2.lastIndex === 4')); eval(t.TEST('result.index === 3')); eval(t.TEST('t.unify(result.indices, [[3, 4]])')); result = re2.exec('abca'); eval(t.TEST('re2.lastIndex === 0')); eval(t.TEST('result === null')); }, function test_bufferVsString(t) { 'use strict'; const re2 = new RE2('.', 'g'), pattern = 'abcdefg'; re2.lastIndex = 2; const result1 = re2.exec(pattern); re2.lastIndex = 2; const result2 = re2.exec(Buffer.from(pattern)); eval(t.TEST("result1[0] === 'c'")); eval(t.TEST("t.unify(result2[0], Buffer.from('c'))")); eval(t.TEST('result1.index === 2')); eval(t.TEST('result2.index === 2')); } ]); node-re2-1.20.12/tests/test_general.js000066400000000000000000000162031462511572500174560ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ function test_generalCtr(t) { "use strict"; eval(t.TEST("!!RE2")); eval(t.TEST("RE2.toString() === 'function RE2() { [native code] }'")); eval(t.TEST("!!RE2.prototype")); }, function test_generalInst(t) { "use strict"; var re1 = new RE2("\\d+"); eval(t.TEST("!!re1")); eval(t.TEST("re1 instanceof RE2")); var re2 = RE2("\\d+"); eval(t.TEST("!!re2")); eval(t.TEST("re2 instanceof RE2")); compare(re1, re2, t); re1 = new RE2("\\d+", "m"); eval(t.TEST("!!re1")); eval(t.TEST("re1 instanceof RE2")); re2 = RE2("\\d+", "m"); eval(t.TEST("!!re2")); eval(t.TEST("re2 instanceof RE2")); compare(re1, re2, t); }, function test_instErrors(t) { try { var re = new RE2([]); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e instanceof TypeError")); } try { var re = new RE2({}); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e instanceof TypeError")); } try { var re = new RE2(new Date()); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e instanceof TypeError")); } try { var re = new RE2(null); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e instanceof TypeError")); } try { var re = new RE2(); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e instanceof TypeError")); } try { var re = RE2(); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e instanceof TypeError")); } try { var re = RE2({ toString() { throw "corner"; } }); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e instanceof TypeError")); } }, function test_generalIn(t) { "use strict"; var re = new RE2("\\d+"); eval(t.TEST("'exec' in re")); eval(t.TEST("'test' in re")); eval(t.TEST("'match' in re")); eval(t.TEST("'replace' in re")); eval(t.TEST("'search' in re")); eval(t.TEST("'split' in re")); eval(t.TEST("'source' in re")); eval(t.TEST("'flags' in re")); eval(t.TEST("'global' in re")); eval(t.TEST("'ignoreCase' in re")); eval(t.TEST("'multiline' in re")); eval(t.TEST("'dotAll' in re")); eval(t.TEST("'sticky' in re")); eval(t.TEST("'lastIndex' in re")); }, function test_generalPresent(t) { "use strict"; var re = new RE2("\\d+"); eval(t.TEST("typeof re.exec == 'function'")); eval(t.TEST("typeof re.test == 'function'")); eval(t.TEST("typeof re.match == 'function'")); eval(t.TEST("typeof re.replace == 'function'")); eval(t.TEST("typeof re.search == 'function'")); eval(t.TEST("typeof re.split == 'function'")); eval(t.TEST("typeof re.source == 'string'")); eval(t.TEST("typeof re.flags == 'string'")); eval(t.TEST("typeof re.global == 'boolean'")); eval(t.TEST("typeof re.ignoreCase == 'boolean'")); eval(t.TEST("typeof re.multiline == 'boolean'")); eval(t.TEST("typeof re.dotAll == 'boolean'")); eval(t.TEST("typeof re.sticky == 'boolean'")); eval(t.TEST("typeof re.lastIndex == 'number'")); }, function test_generalLastIndex(t) { "use strict"; var re = new RE2("\\d+"); eval(t.TEST("re.lastIndex === 0")); re.lastIndex = 5; eval(t.TEST("re.lastIndex === 5")); re.lastIndex = 0; eval(t.TEST("re.lastIndex === 0")); }, function test_generalRegExp(t) { "use strict"; var re1 = new RegExp("\\d+"); var re2 = new RE2("\\d+"); compare(re1, re2, t); re2 = new RE2(re1); compare(re1, re2, t); re1 = new RegExp("a", "ig"); re2 = new RE2("a", "ig"); compare(re1, re2, t); re2 = new RE2(re1); compare(re1, re2, t); re1 = /\s/gm; re2 = new RE2("\\s", "mg"); compare(re1, re2, t); re2 = new RE2(re1); compare(re1, re2, t); re2 = new RE2(/\s/gm); compare(/\s/gm, re2, t); re1 = new RE2("b", "gm"); re2 = new RE2(re1); compare(re1, re2, t); re1 = new RE2("b", "sgm"); re2 = new RE2(re1); compare(re1, re2, t); re2 = new RE2(/\s/sgm); compare(/\s/sgm, re2, t); }, function test_utf8(t) { "use strict"; var s = "Привет!"; eval(t.TEST("s.length === 7")); eval(t.TEST("RE2.getUtf8Length(s) === 13")); var b = new Buffer(s); eval(t.TEST("b.length === 13")); eval(t.TEST("RE2.getUtf16Length(b) === 7")); var s2 = "\u{1F603}"; eval(t.TEST("s2.length === 2")); eval(t.TEST("RE2.getUtf8Length(s2) === 4")); var b2 = new Buffer(s2); eval(t.TEST("b2.length === 4")); eval(t.TEST("RE2.getUtf16Length(b2) === 2")); var s3 = "\uD83D"; eval(t.TEST("s3.length === 1")); eval(t.TEST("RE2.getUtf8Length(s3) === 3")); var s4 = "🤡"; eval(t.TEST("s4.length === 2")); eval(t.TEST("RE2.getUtf8Length(s4) === 4")); eval(t.TEST("RE2.getUtf16Length(Buffer.from(s4, 'utf8')) === s4.length")); var b3 = new Buffer([0xF0]); eval(t.TEST("b3.length === 1")); eval(t.TEST("RE2.getUtf16Length(b3) === 2")); try { RE2.getUtf8Length({ toString() { throw "corner"; } }); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e === 'corner'")); } eval(t.TEST("RE2.getUtf16Length({ toString() { throw 'corner'; } }) === -1")); }, function test_flags(t) { "use strict"; var re = new RE2("a", "u"); eval(t.TEST("re.flags === 'u'")); re = new RE2("a", "iu"); eval(t.TEST("re.flags === 'iu'")); re = new RE2("a", "mu"); eval(t.TEST("re.flags === 'mu'")); re = new RE2("a", "gu"); eval(t.TEST("re.flags === 'gu'")); re = new RE2("a", "yu"); eval(t.TEST("re.flags === 'uy'")); re = new RE2("a", "yiu"); eval(t.TEST("re.flags === 'iuy'")); re = new RE2("a", "yigu"); eval(t.TEST("re.flags === 'giuy'")); re = new RE2("a", "miu"); eval(t.TEST("re.flags === 'imu'")); re = new RE2("a", "ygu"); eval(t.TEST("re.flags === 'guy'")); re = new RE2("a", "myu"); eval(t.TEST("re.flags === 'muy'")); re = new RE2("a", "migyu"); eval(t.TEST("re.flags === 'gimuy'")); re = new RE2("a", "smigyu"); eval(t.TEST("re.flags === 'gimsuy'")); }, function test_flags_2nd(t) { "use strict"; var re = new RE2(/a/, "u"); eval(t.TEST("re.flags === 'u'")); re = new RE2(/a/gm, "iu"); eval(t.TEST("re.flags === 'iu'")); re = new RE2(/a/ig, "mu"); eval(t.TEST("re.flags === 'mu'")); re = new RE2(/a/g, "gu"); eval(t.TEST("re.flags === 'gu'")); re = new RE2(/a/m, "yu"); eval(t.TEST("re.flags === 'uy'")); re = new RE2(/a/, "yiu"); eval(t.TEST("re.flags === 'iuy'")); re = new RE2(/a/gim, "yigu"); eval(t.TEST("re.flags === 'giuy'")); re = new RE2(/a/gm, "miu"); eval(t.TEST("re.flags === 'imu'")); re = new RE2(/a/i, "ygu"); eval(t.TEST("re.flags === 'guy'")); re = new RE2(/a/g, "myu"); eval(t.TEST("re.flags === 'muy'")); re = new RE2(/a/, "migyu"); eval(t.TEST("re.flags === 'gimuy'")); re = new RE2(/a/s, "smigyu"); eval(t.TEST("re.flags === 'gimsuy'")); } ]); // utilitites function compare(re1, re2, t) { // compares regular expression objects eval(t.TEST("re1.source === re2.source")); eval(t.TEST("re1.global === re2.global")); eval(t.TEST("re1.ignoreCase === re2.ignoreCase")); eval(t.TEST("re1.multiline === re2.multiline")); // eval(t.TEST("re1.unicode === re2.unicode")); eval(t.TEST("re1.sticky === re2.sticky")); } node-re2-1.20.12/tests/test_groups.js000066400000000000000000000054121462511572500173600ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ function test_groupsNormal(t) { "use strict"; eval(t.TEST("RE2('(?\\\\d)').test('9')")); eval(t.TEST("t.unify(RE2('(?-)', 'g').match('a-b-c'), ['-', '-'])")); eval(t.TEST("t.unify(RE2('(?-)').split('a-b-c'), ['a', '-', 'b', '-', 'c'])")); eval(t.TEST("RE2('(?-)', 'g').search('a-b-c') === 1")); }, function test_groupsExec(t) { "use strict"; var result = new RE2('(\\d)').exec('k9'); eval(t.TEST("result")); eval(t.TEST("result[0] === '9'")); eval(t.TEST("result[1] === '9'")); eval(t.TEST("result.index === 1")); eval(t.TEST("result.input === 'k9'")); eval(t.TEST("typeof result.groups == 'undefined'")); result = new RE2('(?\\d)').exec('k9'); eval(t.TEST("result")); eval(t.TEST("result[0] === '9'")); eval(t.TEST("result[1] === '9'")); eval(t.TEST("result.index === 1")); eval(t.TEST("result.input === 'k9'")); eval(t.TEST("t.unify(result.groups, {a: '9'})")); }, function test_groupsMatch(t) { "use strict"; var result = new RE2('(\\d)').match('k9'); eval(t.TEST("result")); eval(t.TEST("result[0] === '9'")); eval(t.TEST("result[1] === '9'")); eval(t.TEST("result.index === 1")); eval(t.TEST("result.input === 'k9'")); eval(t.TEST("typeof result.groups == 'undefined'")); result = new RE2('(?\\d)').match('k9'); eval(t.TEST("result")); eval(t.TEST("result[0] === '9'")); eval(t.TEST("result[1] === '9'")); eval(t.TEST("result.index === 1")); eval(t.TEST("result.input === 'k9'")); eval(t.TEST("t.unify(result.groups, {a: '9'})")); }, function test_groupsMatch(t) { "use strict"; eval(t.TEST("RE2('(?\\\\w)(?\\\\d)', 'g').replace('a1b2c', '$2$1') === '1a2bc'")); eval(t.TEST("RE2('(?\\\\w)(?\\\\d)', 'g').replace('a1b2c', '$$') === '1a2bc'")); eval(t.TEST("RE2('(?\\\\w)(?\\\\d)', 'g').replace('a1b2c', replacerByNumbers) === '1a2bc'")); eval(t.TEST("RE2('(?\\\\w)(?\\\\d)', 'g').replace('a1b2c', replacerByNames) === '1a2bc'")); function replacerByNumbers(match, group1, group2, index, source, groups) { return group2 + group1; } function replacerByNames(match, group1, group2, index, source, groups) { return groups.d + groups.w; } }, function test_groupsInvalid(t) { "use strict"; try { RE2('(?<>.)'); t.test(false); // shouldn'be here } catch(e) { eval(t.TEST("e instanceof SyntaxError")); } // TODO: do we need to enforce the correct id? // try { // RE2('(?<1>.)'); // t.test(false); // shouldn'be here // } catch(e) { // eval(t.TEST("e instanceof SyntaxError")); // } try { RE2('(?.)(?.)'); t.test(false); // shouldn'be here } catch(e) { eval(t.TEST("e instanceof SyntaxError")); } } ]); node-re2-1.20.12/tests/test_invalid.js000066400000000000000000000015631462511572500174720ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ function test_inval(t) { "use strict"; var threw; // Backreferences threw = false; try { new RE2(/(a)\1/); } catch (e) { threw = true; eval(t.TEST("e instanceof SyntaxError")); eval(t.TEST("e.message === 'invalid escape sequence: \\\\1'")); } t.test(threw); // Lookahead assertions // Positive threw = false; try { new RE2(/a(?=b)/); } catch (e) { threw = true; eval(t.TEST("e instanceof SyntaxError")); eval(t.TEST("e.message === 'invalid perl operator: (?='")); } t.test(threw); // Negative threw = false; try { new RE2(/a(?!b)/); } catch (e) { threw = true; eval(t.TEST("e instanceof SyntaxError")); eval(t.TEST("e.message === 'invalid perl operator: (?!'")); } t.test(threw); }, ]); node-re2-1.20.12/tests/test_match.js000066400000000000000000000113051462511572500171330ustar00rootroot00000000000000'use strict'; var unit = require('heya-unit'); var RE2 = require('../re2'); // tests unit.add(module, [ // These tests are copied from MDN: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match function test_match(t) { 'use strict'; var str = 'For more information, see Chapter 3.4.5.1'; var re = new RE2(/(chapter \d+(\.\d)*)/i); var result = re.match(str); eval(t.TEST('result.input === str')); eval(t.TEST('result.index === 26')); eval(t.TEST('result.length === 3')); eval(t.TEST("result[0] === 'Chapter 3.4.5.1'")); eval(t.TEST("result[1] === 'Chapter 3.4.5.1'")); eval(t.TEST("result[2] === '.1'")); }, function test_matchGlobal(t) { 'use strict'; var re = new RE2(/[A-E]/gi); var result = re.match( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ); eval( t.TEST( "t.unify(result, ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e'])" ) ); }, function test_matchFail(t) { 'use strict'; var re = new RE2('(a+)?(b+)?'); var result = re.match('aaabb'); eval(t.TEST("result[1] === 'aaa'")); eval(t.TEST("result[2] === 'bb'")); result = re.match('aaacbb'); eval(t.TEST("result[1] === 'aaa'")); eval(t.TEST('result[2] === undefined')); }, function test_matchInvalid(t) { 'use strict'; var re = RE2(''); try { re.match({ toString() { throw 'corner'; } }); t.test(false); // shouldn't be here } catch (e) { eval(t.TEST("e === 'corner'")); } }, // Unicode tests function test_matchUnicode(t) { 'use strict'; var str = 'Это ГЛАВА 3.4.5.1'; var re = new RE2(/(глава \d+(\.\d)*)/i); var result = re.match(str); eval(t.TEST('result.input === str')); eval(t.TEST('result.index === 4')); eval(t.TEST('result.length === 3')); eval(t.TEST("result[0] === 'ГЛАВА 3.4.5.1'")); eval(t.TEST("result[1] === 'ГЛАВА 3.4.5.1'")); eval(t.TEST("result[2] === '.1'")); }, // Buffer tests function test_matchBuffer(t) { 'use strict'; var buf = new Buffer('Это ГЛАВА 3.4.5.1'); var re = new RE2(/(глава \d+(\.\d)*)/i); var result = re.match(buf); eval(t.TEST('result.input instanceof Buffer')); eval(t.TEST('result.length === 3')); eval(t.TEST('result[0] instanceof Buffer')); eval(t.TEST('result[1] instanceof Buffer')); eval(t.TEST('result[2] instanceof Buffer')); eval(t.TEST('result.input === buf')); eval(t.TEST('result.index === 7')); eval( t.TEST("result.input.toString('utf8', result.index) === 'ГЛАВА 3.4.5.1'") ); eval(t.TEST("result[0].toString() === 'ГЛАВА 3.4.5.1'")); eval(t.TEST("result[1].toString() === 'ГЛАВА 3.4.5.1'")); eval(t.TEST("result[2].toString() === '.1'")); }, // Sticky tests function test_matchSticky(t) { 'use strict'; var re = new RE2('\\s+', 'y'); eval(t.TEST("re.match('Hello world, how are you?') === null")); re.lastIndex = 5; var result = re.match('Hello world, how are you?'); eval(t.TEST("t.unify(result, [' '])")); eval(t.TEST('result.index === 5')); eval(t.TEST('re.lastIndex === 6')); var re2 = new RE2('\\s+', 'gy'); eval(t.TEST("re2.match('Hello world, how are you?') === null")); re2.lastIndex = 5; eval(t.TEST("re2.match('Hello world, how are you?') === null")); var re3 = new RE2(/[A-E]/giy); var result3 = re3.match( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ); eval(t.TEST("t.unify(result3, ['A', 'B', 'C', 'D', 'E'])")); }, // hasIndices tests function test_matchHasIndices(t) { 'use strict'; const re = new RE2('(aa)(?b)?(?ccc)', 'd'), str1 = '1aabccc2', str2 = '1aaccc2'; eval(t.TEST("t.unify(str1.match(re), re.exec(str1))")); eval(t.TEST("t.unify(str2.match(re), re.exec(str2))")); }, function test_matchHasIndicesGlobal(t) { 'use strict'; const re = new RE2('(?a)', 'dg'), result = 'abca'.match(re); eval(t.TEST("t.unify(result, ['a', 'a'])")); eval(t.TEST("!('indices' in result)")); eval(t.TEST("!('groups' in result)")); }, function test_matchLastIndex(t) { 'use strict'; const re = new RE2(/./g), pattern = 'Я123'; re.lastIndex = 2; const result1 = pattern.match(re); eval(t.TEST("t.unify(result1, ['Я', '1', '2', '3'])")); eval(t.TEST("re.lastIndex === 0")); const re2 = RE2(re); re2.lastIndex = 2; const result2 = re2.match(Buffer.from(pattern)); eval(t.TEST("t.unify(result2.map(b => b.toString()), ['Я', '1', '2', '3'])")); eval(t.TEST("re2.lastIndex === 0")); } ]); node-re2-1.20.12/tests/test_matchAll.js000066400000000000000000000046731462511572500175760ustar00rootroot00000000000000'use strict'; const unit = require('heya-unit'); const RE2 = require('../re2'); // tests unit.add(module, [ // These tests are copied from MDN: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll function test_matchAll(t) { 'use strict'; const str = 'test1test2'; const re = new RE2(/t(e)(st(\d?))/g); const result = Array.from(str.matchAll(re)); eval(t.TEST('result.length === 2')); eval(t.TEST('result[0].input === str')); eval(t.TEST('result[0].index === 0')); eval(t.TEST('result[0].length === 4')); eval(t.TEST("result[0][0] === 'test1'")); eval(t.TEST("result[0][1] === 'e'")); eval(t.TEST("result[0][2] === 'st1'")); eval(t.TEST("result[0][3] === '1'")); eval(t.TEST('result[1].input === str')); eval(t.TEST('result[1].index === 5')); eval(t.TEST('result[1].length === 4')); eval(t.TEST("result[1][0] === 'test2'")); eval(t.TEST("result[1][1] === 'e'")); eval(t.TEST("result[1][2] === 'st2'")); eval(t.TEST("result[1][3] === '2'")); }, function test_matchAll_iterator(t) { 'use strict'; const str = 'table football, foosball'; const re = new RE2('foo[a-z]*', 'g'); const expected = [ {start: 6, finish: 14}, {start: 16, finish: 24} ]; let i = 0; for (const match of str.matchAll(re)) { eval(t.TEST('match.index === expected[i].start')); eval(t.TEST('match.index + match[0].length === expected[i].finish')); ++i; } }, function test_matchAll_non_global(t) { 'use strict'; const re = RE2('b'); try { 'abc'.matchAll(re); t.test(false); // shouldn't be here } catch (e) { eval(t.TEST('e instanceof TypeError')); } }, function test_matchAll_lastIndex(t) { 'use strict'; const re = RE2('[a-c]', 'g'); re.lastIndex = 1; const expected = ['b', 'c']; let i = 0; for (const match of 'abc'.matchAll(re)) { eval(t.TEST('re.lastIndex === 1')); eval(t.TEST('match[0] === expected[i]')); ++i; } }, function test_matchAll_empty_match(t) { 'use strict'; const str = 'foo'; // Matches empty strings, but should not cause an infinite loop const re = new RE2('(?:)', 'g'); const result = Array.from(str.matchAll(re)); eval(t.TEST('result.length === str.length + 1')); for (let i = 0; i < result.length; ++i) { eval(t.TEST('result[i][0] === ""')); } } ]); node-re2-1.20.12/tests/test_new.js000066400000000000000000000024471462511572500166370ustar00rootroot00000000000000"use strict"; const unit = require("heya-unit"); const RE2 = require("../re2"); // tests unit.add(module, [ function test_newUnicodeWarnOnce(t) { "use strict"; let errorMessage = null; const consoleError = console.error; console.error = msg => (errorMessage = msg); RE2.unicodeWarningLevel = "warnOnce"; let a = new RE2(".*"); eval(t.TEST("errorMessage")); errorMessage = null; a = new RE2(".?"); eval(t.TEST("errorMessage === null")); RE2.unicodeWarningLevel = "warnOnce"; a = new RE2(".+"); eval(t.TEST("errorMessage")); RE2.unicodeWarningLevel = "nothing"; console.error = consoleError; }, function test_newUnicodeWarn(t) { "use strict"; let errorMessage = null; const consoleError = console.error; console.error = msg => (errorMessage = msg); RE2.unicodeWarningLevel = "warn"; let a = new RE2(".*"); eval(t.TEST("errorMessage")); errorMessage = null; a = new RE2(".?"); eval(t.TEST("errorMessage")); RE2.unicodeWarningLevel = "nothing"; console.error = consoleError; }, function test_newUnicodeWarn(t) { "use strict"; RE2.unicodeWarningLevel = "throw"; try { let a = new RE2("."); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e instanceof SyntaxError")); } RE2.unicodeWarningLevel = "nothing"; } ]); node-re2-1.20.12/tests/test_prototype.js000066400000000000000000000011361462511572500201050ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ function test_prototype(t) { "use strict"; eval(t.TEST("RE2.prototype.source === '(?:)'")); eval(t.TEST("RE2.prototype.flags === ''")); eval(t.TEST("RE2.prototype.global === undefined")); eval(t.TEST("RE2.prototype.ignoreCase === undefined")); eval(t.TEST("RE2.prototype.multiline === undefined")); eval(t.TEST("RE2.prototype.dotAll === undefined")); eval(t.TEST("RE2.prototype.sticky === undefined")); eval(t.TEST("RE2.prototype.lastIndex === undefined")); } ]); node-re2-1.20.12/tests/test_replace.js000066400000000000000000000264151462511572500174620ustar00rootroot00000000000000'use strict'; var unit = require('heya-unit'); var RE2 = require('../re2'); // tests unit.add(module, [ // These tests are copied from MDN: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace function test_replaceString(t) { 'use strict'; var re = new RE2(/apples/gi); var result = re.replace( 'Apples are round, and apples are juicy.', 'oranges' ); eval(t.TEST("result === 'oranges are round, and oranges are juicy.'")); re = new RE2(/xmas/i); result = re.replace('Twas the night before Xmas...', 'Christmas'); eval(t.TEST("result === 'Twas the night before Christmas...'")); re = new RE2(/(\w+)\s(\w+)/); result = re.replace('John Smith', '$2, $1'); eval(t.TEST("result === 'Smith, John'")); }, function test_replaceFunReplacer(t) { 'use strict'; function replacer(match, p1, p2, p3, offset, string) { // p1 is nondigits, p2 digits, and p3 non-alphanumerics return [p1, p2, p3].join(' - '); } var re = new RE2(/([^\d]*)(\d*)([^\w]*)/); var result = re.replace('abc12345#$*%', replacer); eval(t.TEST("result === 'abc - 12345 - #$*%'")); }, function test_replaceFunUpper(t) { 'use strict'; function upperToHyphenLower(match) { return '-' + match.toLowerCase(); } var re = new RE2(/[A-Z]/g); var result = re.replace('borderTop', upperToHyphenLower); eval(t.TEST("result === 'border-top'")); }, function test_replaceFunConvert(t) { 'use strict'; function convert(str, p1, offset, s) { return ((p1 - 32) * 5) / 9 + 'C'; } var re = new RE2(/(\d+(?:\.\d*)?)F\b/g); eval(t.TEST("re.replace('32F', convert) === '0C'")); eval(t.TEST("re.replace('41F', convert) === '5C'")); eval(t.TEST("re.replace('50F', convert) === '10C'")); eval(t.TEST("re.replace('59F', convert) === '15C'")); eval(t.TEST("re.replace('68F', convert) === '20C'")); eval(t.TEST("re.replace('77F', convert) === '25C'")); eval(t.TEST("re.replace('86F', convert) === '30C'")); eval(t.TEST("re.replace('95F', convert) === '35C'")); eval(t.TEST("re.replace('104F', convert) === '40C'")); eval(t.TEST("re.replace('113F', convert) === '45C'")); eval(t.TEST("re.replace('212F', convert) === '100C'")); }, { test: function test_replaceFunLoop(t) { 'use strict'; RE2(/(x_*)|(-)/g).replace('x-x_', function (match, p1, p2) { if (p1) { t.info('on: ' + p1.length); } if (p2) { t.info('off: 1'); } }); }, logs: [{text: 'on: 1'}, {text: 'off: 1'}, {text: 'on: 2'}] }, function test_replaceInvalid(t) { 'use strict'; var re = RE2(''); try { re.replace( { toString() { throw 'corner1'; } }, '' ); t.test(false); // shouldn't be here } catch (e) { eval(t.TEST("e === 'corner1'")); } try { re.replace('', { toString() { throw 'corner2'; } }); t.test(false); // shouldn't be here } catch (e) { eval(t.TEST("e === 'corner2'")); } var arg2Stringified = false; try { re.replace( { toString() { throw 'corner1'; } }, { toString() { arg2Stringified = true; throw 'corner2'; } } ); t.test(false); // shouldn't be here } catch (e) { eval(t.TEST("e === 'corner1'")); eval(t.TEST('!arg2Stringified')); } try { re.replace('', () => { throw 'corner2'; }); t.test(false); // shouldn't be here } catch (e) { eval(t.TEST("e === 'corner2'")); } try { re.replace('', () => ({ toString() { throw 'corner2'; } })); t.test(false); // shouldn't be here } catch (e) { eval(t.TEST("e === 'corner2'")); } }, // Unicode tests function test_replaceStrUnicode(t) { 'use strict'; var re = new RE2(/яблоки/gi); var result = re.replace('Яблоки красны, яблоки сочны.', 'апельсины'); eval(t.TEST("result === 'апельсины красны, апельсины сочны.'")); re = new RE2(/иван/i); result = re.replace('Могуч Иван Иванов...', 'Сидор'); eval(t.TEST("result === 'Могуч Сидор Иванов...'")); re = new RE2(/иван/gi); result = re.replace('Могуч Иван Иванов...', 'Сидор'); eval(t.TEST("result === 'Могуч Сидор Сидоров...'")); re = new RE2(/([а-яё]+)\s+([а-яё]+)/i); result = re.replace('Пётр Петров', '$2, $1'); eval(t.TEST("result === 'Петров, Пётр'")); }, function test_replaceFunUnicode(t) { 'use strict'; function replacer(match, offset, string) { t.test(typeof offset == 'number'); t.test(typeof string == 'string'); t.test(offset === 0 || offset === 7); t.test(string === 'ИВАН и пЁтр'); return match.charAt(0).toUpperCase() + match.substr(1).toLowerCase(); } var re = new RE2(/(?:иван|пётр|сидор)/gi); var result = re.replace('ИВАН и пЁтр', replacer); eval(t.TEST("result === 'Иван и Пётр'")); }, // Buffer tests function test_replaceStrBuffer(t) { 'use strict'; var re = new RE2(/яблоки/gi); var result = re.replace( new Buffer('Яблоки красны, яблоки сочны.'), 'апельсины' ); eval(t.TEST('result instanceof Buffer')); eval(t.TEST("result.toString() === 'апельсины красны, апельсины сочны.'")); result = re.replace( new Buffer('Яблоки красны, яблоки сочны.'), new Buffer('апельсины') ); eval(t.TEST('result instanceof Buffer')); eval(t.TEST("result.toString() === 'апельсины красны, апельсины сочны.'")); result = re.replace( 'Яблоки красны, яблоки сочны.', new Buffer('апельсины') ); eval(t.TEST("typeof result == 'string'")); eval(t.TEST("result === 'апельсины красны, апельсины сочны.'")); }, function test_replaceFunBuffer(t) { 'use strict'; function replacer(match, offset, string) { eval(t.TEST('match instanceof Buffer')); eval(t.TEST("typeof offset == 'number'")); eval(t.TEST("typeof string == 'string'")); eval(t.TEST('offset === 0 || offset === 12')); eval(t.TEST("string === 'ИВАН и пЁтр'")); var s = match.toString(); return s.charAt(0).toUpperCase() + s.substr(1).toLowerCase(); } replacer.useBuffers = true; var re = new RE2(/(?:иван|пётр|сидор)/gi); var result = re.replace('ИВАН и пЁтр', replacer); eval(t.TEST("typeof result == 'string'")); eval(t.TEST("result === 'Иван и Пётр'")); }, function test_replace0(t) { 'use strict'; function replacer(match) { return 'MARKER' + match; } var re = new RE2(/^/g); var result = re.replace('foo bar', 'MARKER'); eval(t.TEST("result === 'MARKERfoo bar'")); result = re.replace('foo bar', replacer); eval(t.TEST("result === 'MARKERfoo bar'")); re = new RE2(/$/g); result = re.replace('foo bar', 'MARKER'); eval(t.TEST("result === 'foo barMARKER'")); result = re.replace('foo bar', replacer); eval(t.TEST("result === 'foo barMARKER'")); re = new RE2(/\b/g); result = re.replace('foo bar', 'MARKER'); eval(t.TEST("result === 'MARKERfooMARKER MARKERbarMARKER'")); result = re.replace('foo bar', replacer); eval(t.TEST("result === 'MARKERfooMARKER MARKERbarMARKER'")); }, // Sticky tests function test_replaceSticky(t) { 'use strict'; var re = new RE2(/[A-E]/y); eval(t.TEST("re.replace('ABCDEFABCDEF', '!') === '!BCDEFABCDEF'")); eval(t.TEST("re.replace('ABCDEFABCDEF', '!') === 'A!CDEFABCDEF'")); eval(t.TEST("re.replace('ABCDEFABCDEF', '!') === 'AB!DEFABCDEF'")); eval(t.TEST("re.replace('ABCDEFABCDEF', '!') === 'ABC!EFABCDEF'")); eval(t.TEST("re.replace('ABCDEFABCDEF', '!') === 'ABCD!FABCDEF'")); eval(t.TEST("re.replace('ABCDEFABCDEF', '!') === 'ABCDEFABCDEF'")); eval(t.TEST("re.replace('ABCDEFABCDEF', '!') === '!BCDEFABCDEF'")); var re2 = new RE2(/[A-E]/gy); eval(t.TEST("re2.replace('ABCDEFABCDEF', '!') === '!!!!!FABCDEF'")); eval(t.TEST("re2.replace('FABCDEFABCDE', '!') === 'FABCDEFABCDE'")); re2.lastIndex = 3; eval(t.TEST("re2.replace('ABCDEFABCDEF', '!') === '!!!!!FABCDEF'")); eval(t.TEST('re2.lastIndex === 0')); }, // Non-matches function test_replaceOneNonMatch(t) { 'use strict'; function replacer(match, capture, offset, string) { t.test(typeof offset == 'number'); t.test(typeof match == 'string'); t.test(typeof string == 'string'); t.test(typeof capture == 'undefined'); t.test(offset === 0); t.test(string === 'hello '); return ''; } var re = new RE2(/hello (world)?/); re.replace('hello ', replacer); }, function test_replaceTwoNonMatches(t) { 'use strict'; function replacer(match, capture1, capture2, offset, string, groups) { t.test(typeof offset == 'number'); t.test(typeof match == 'string'); t.test(typeof string == 'string'); t.test(typeof capture1 == 'undefined'); t.test(typeof capture2 == 'undefined'); t.test(offset === 1); t.test(match === 'b & y'); t.test(string === 'ab & yz'); t.test(typeof groups == 'object'); t.test(Object.keys(groups).length == 2); t.test(groups.a === undefined); t.test(groups.b == undefined); return ''; } var re = new RE2(/b(?1)? & (?2)?y/); var result = re.replace('ab & yz', replacer); eval(t.TEST("result === 'az'")); }, function test_replaceGroupSimple(t) { 'use strict'; var re = new RE2(/(2)/); var result = re.replace('123', '$0'); eval(t.TEST("result === '1$03'")); result = re.replace('123', '$1'); eval(t.TEST("result === '123'")); result = re.replace('123', '$2'); eval(t.TEST("result === '1$23'")); result = re.replace('123', '$00'); eval(t.TEST("result === '1$003'")); result = re.replace('123', '$01'); eval(t.TEST("result === '123'")); result = re.replace('123', '$02'); eval(t.TEST("result === '1$023'")); }, function test_replaceGroupCases(t) { 'use strict'; var re = new RE2(/(test)/g); var result = re.replace('123', '$1$20'); eval(t.TEST("result === '123'")); re = new RE2(/(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)/g); result = re.replace('abcdefghijklmnopqrstuvwxyz123', '$10$20'); eval(t.TEST("result === 'jb0wo0123'")); re = new RE2(/(.)(.)(.)(.)(.)/g); result = re.replace('abcdefghijklmnopqrstuvwxyz123', '$10$20'); eval(t.TEST("result === 'a0b0f0g0k0l0p0q0u0v0z123'")); re = new RE2(/(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)/g); result = re.replace('abcdefghijklmnopqrstuvwxyz123', '$10$20'); eval(t.TEST("result === 'jtvwxyz123'")); re = new RE2(/abcd/g); result = re.replace('abcd123', '$1$2'); eval(t.TEST("result === '$1$2123'")); } ]); node-re2-1.20.12/tests/test_search.js000066400000000000000000000042041462511572500173040ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ function test_search(t) { "use strict"; var str = "Total is 42 units."; var re = new RE2(/\d+/i); var result = re.search(str); eval(t.TEST("result === 9")); re = new RE2("\\b[a-z]+\\b"); result = re.search(str); eval(t.TEST("result === 6")); re = new RE2("\\b\\w+\\b"); result = re.search(str); eval(t.TEST("result === 0")); re = new RE2("z", "gm"); result = re.search(str); eval(t.TEST("result === -1")); }, function test_searchInvalid(t) { "use strict"; var re = RE2(''); try { re.search({ toString() { throw "corner"; } }); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e === 'corner'")); } }, function test_searchUnicode(t) { "use strict"; var str = "Всего 42 штуки."; var re = new RE2(/\d+/i); var result = re.search(str); eval(t.TEST("result === 6")); re = new RE2("\\s[а-я]+"); result = re.search(str); eval(t.TEST("result === 8")); re = new RE2("[а-яА-Я]+"); result = re.search(str); eval(t.TEST("result === 0")); re = new RE2("z", "gm"); result = re.search(str); eval(t.TEST("result === -1")); }, function test_searchBuffer(t) { "use strict"; var buf = new Buffer("Всего 42 штуки."); var re = new RE2(/\d+/i); var result = re.search(buf); eval(t.TEST("result === 11")); re = new RE2("\\s[а-я]+"); result = re.search(buf); eval(t.TEST("result === 13")); re = new RE2("[а-яА-Я]+"); result = re.search(buf); eval(t.TEST("result === 0")); re = new RE2("z", "gm"); result = re.search(buf); eval(t.TEST("result === -1")); }, function test_searchSticky(t) { "use strict"; var str = "Total is 42 units."; var re = new RE2(/\d+/y); var result = re.search(str); eval(t.TEST("result === -1")); re = new RE2("\\b[a-z]+\\b", "y"); result = re.search(str); eval(t.TEST("result === -1")); re = new RE2("\\b\\w+\\b", "y"); result = re.search(str); eval(t.TEST("result === 0")); re = new RE2("z", "gmy"); result = re.search(str); eval(t.TEST("result === -1")); } ]); node-re2-1.20.12/tests/test_source.js000066400000000000000000000037251462511572500173460ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ function test_sourceIdentity(t) { "use strict"; var re = new RE2("a\\cM\\u34\\u1234\\u10abcdz"); eval(t.TEST("re.source === 'a\\\\cM\\\\u34\\\\u1234\\\\u10abcdz'")); re = new RE2("a\\cM\\u34\\u1234\\u{10abcd}z"); eval(t.TEST("re.source === 'a\\\\cM\\\\u34\\\\u1234\\\\u{10abcd}z'")); re = new RE2(""); eval(t.TEST("re.source === '(?:)'")); re = new RE2("foo/bar"); eval(t.TEST("re.source === 'foo\\\\/bar'")); re = new RE2("foo\\/bar"); eval(t.TEST("re.source === 'foo\\\\/bar'")); re = new RE2("(?bar)", "u"); eval(t.TEST("re.source === '(?bar)'")); }, function test_sourceTranslation(t) { "use strict"; var re = new RE2("a\\cM\\u34\\u1234\\u10abcdz"); eval(t.TEST("re.internalSource === 'a\\\\x0D\\\\x{34}\\\\x{1234}\\\\x{10ab}cdz'")); re = new RE2("a\\cM\\u34\\u1234\\u{10abcd}z"); eval(t.TEST("re.internalSource === 'a\\\\x0D\\\\x{34}\\\\x{1234}\\\\x{10abcd}z'")); re = new RE2(""); eval(t.TEST("re.internalSource === '(?:)'")); re = new RE2("foo/bar"); eval(t.TEST("re.internalSource === 'foo\\\\/bar'")); re = new RE2("foo\\/bar"); eval(t.TEST("re.internalSource === 'foo\\\\/bar'")); re = new RE2("(?bar)", "u"); eval(t.TEST("re.internalSource === '(?Pbar)'")); re = new RE2("foo\\/bar", "m"); eval(t.TEST("re.internalSource === '(?m)foo\\\\/bar'")); }, function test_sourceBackSlashes(t) { "use strict"; function compare(source, expected) { var s = new RE2(source).source; eval(t.TEST("s === expected")); } compare("a/b", "a\\/b"); compare("a\/b", "a\\/b"); compare("a\\/b", "a\\/b"); compare("a\\\/b", "a\\/b"); compare("a\\\\/b", "a\\\\\\/b"); compare("a\\\\\/b", "a\\\\\\/b"); compare("/a/b", "\\/a\\/b"); compare("\\/a/b", "\\/a\\/b"); compare("\\/a\\/b", "\\/a\\/b"); compare("\\/a\\\\/b", "\\/a\\\\\\/b"); } ]); node-re2-1.20.12/tests/test_split.js000066400000000000000000000123631462511572500171770ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ // These tests are copied from MDN: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split function test_split(t) { "use strict"; var re = new RE2(/\s+/); var result = re.split("Oh brave new world that has such people in it."); eval(t.TEST("t.unify(result, ['Oh', 'brave', 'new', 'world', 'that', 'has', 'such', 'people', 'in', 'it.'])")); re = new RE2(","); result = re.split("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"); eval(t.TEST("t.unify(result, ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'])")); re = new RE2(","); result = re.split(",Jan,Feb,Mar,Apr,May,Jun,,Jul,Aug,Sep,Oct,Nov,Dec,"); eval(t.TEST("t.unify(result, ['','Jan','Feb','Mar','Apr','May','Jun','','Jul','Aug','Sep','Oct','Nov','Dec',''])")); re = new RE2(/\s*;\s*/); result = re.split("Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand "); eval(t.TEST("t.unify(result, ['Harry Trump', 'Fred Barney', 'Helen Rigby', 'Bill Abel', 'Chris Hand '])")); re = new RE2(/\s+/); result = re.split("Hello World. How are you doing?", 3); eval(t.TEST("t.unify(result, ['Hello', 'World.', 'How'])")); re = new RE2(/(\d)/); result = re.split("Hello 1 word. Sentence number 2."); eval(t.TEST("t.unify(result, ['Hello ', '1', ' word. Sentence number ', '2', '.'])")); eval(t.TEST("RE2(/[x-z]*/).split('asdfghjkl').reverse().join('') === 'lkjhgfdsa'")); }, function test_splitInvalid(t) { "use strict"; var re = RE2(''); try { re.split({ toString() { throw "corner"; } }); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e === 'corner'")); } }, function test_cornerCases(t) { "use strict"; var re = new RE2(/1/); var result = re.split("23456"); eval(t.TEST("t.unify(result, ['23456'])")); }, // Unicode tests function test_splitUnicode(t) { "use strict"; var re = new RE2(/\s+/); var result = re.split("Она не понимает, что этим убивает меня."); eval(t.TEST("t.unify(result, ['Она', 'не', 'понимает,', 'что', 'этим', 'убивает', 'меня.'])")); re = new RE2(","); result = re.split("Пн,Вт,Ср,Чт,Пт,Сб,Вс"); eval(t.TEST("t.unify(result, ['Пн','Вт','Ср','Чт','Пт','Сб','Вс'])")); re = new RE2(/\s*;\s*/); result = re.split("Ваня Иванов ;Петро Петренко; Саша Машин ; Маша Сашина"); eval(t.TEST("t.unify(result, ['Ваня Иванов', 'Петро Петренко', 'Саша Машин', 'Маша Сашина'])")); re = new RE2(/\s+/); result = re.split("Привет мир. Как дела?", 3); eval(t.TEST("t.unify(result, ['Привет', 'мир.', 'Как'])")); re = new RE2(/(\d)/); result = re.split("Привет 1 слово. Предложение номер 2."); eval(t.TEST("t.unify(result, ['Привет ', '1', ' слово. Предложение номер ', '2', '.'])")); eval(t.TEST("RE2(/[э-я]*/).split('фывапролд').reverse().join('') === 'длорпавыф'")); }, // Buffer tests function test_splitBuffer(t) { "use strict"; var re = new RE2(/\s+/); var result = re.split(new Buffer("Она не понимает, что этим убивает меня.")); eval(t.TEST("t.unify(verifyBuffer(result, t), ['Она', 'не', 'понимает,', 'что', 'этим', 'убивает', 'меня.'])")); re = new RE2(","); result = re.split(new Buffer("Пн,Вт,Ср,Чт,Пт,Сб,Вс")); eval(t.TEST("t.unify(verifyBuffer(result, t), ['Пн','Вт','Ср','Чт','Пт','Сб','Вс'])")); re = new RE2(/\s*;\s*/); result = re.split(new Buffer("Ваня Иванов ;Петро Петренко; Саша Машин ; Маша Сашина")); eval(t.TEST("t.unify(verifyBuffer(result, t), ['Ваня Иванов', 'Петро Петренко', 'Саша Машин', 'Маша Сашина'])")); re = new RE2(/\s+/); result = re.split(new Buffer("Привет мир. Как дела?"), 3); eval(t.TEST("t.unify(verifyBuffer(result, t), ['Привет', 'мир.', 'Как'])")); re = new RE2(/(\d)/); result = re.split(new Buffer("Привет 1 слово. Предложение номер 2.")); eval(t.TEST("t.unify(verifyBuffer(result, t), ['Привет ', '1', ' слово. Предложение номер ', '2', '.'])")); eval(t.TEST("RE2(/[э-я]*/).split(new Buffer('фывапролд')).map(function(x) { return x.toString(); }).reverse().join('') === 'длорпавыф'")); }, // Sticky tests function test_splitSticky(t) { "use strict"; var re = new RE2(/\s+/y); // sticky is ignored var result = re.split("Oh brave new world that has such people in it."); eval(t.TEST("t.unify(result, ['Oh', 'brave', 'new', 'world', 'that', 'has', 'such', 'people', 'in', 'it.'])")); var result2 = re.split(" Oh brave new world that has such people in it."); eval(t.TEST("t.unify(result2, ['', 'Oh', 'brave', 'new', 'world', 'that', 'has', 'such', 'people', 'in', 'it.'])")); } ]); function verifyBuffer(buf, t) { return buf.map(function(x) { t.test(x instanceof Buffer); return x.toString(); }); } node-re2-1.20.12/tests/test_symbols.js000066400000000000000000000055121462511572500175320ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ function test_match_symbol (t) { "use strict"; if (typeof Symbol == 'undefined' || !Symbol.match) return; var str = "For more information, see Chapter 3.4.5.1"; var re = new RE2(/(chapter \d+(\.\d)*)/i); var result = str.match(re); eval(t.TEST("result.input === str")); eval(t.TEST("result.index === 26")); eval(t.TEST("result.length === 3")); eval(t.TEST("result[0] === 'Chapter 3.4.5.1'")); eval(t.TEST("result[1] === 'Chapter 3.4.5.1'")); eval(t.TEST("result[2] === '.1'")); }, function test_search_symbol (t) { "use strict"; if (typeof Symbol == 'undefined' || !Symbol.search) return; var str = "Total is 42 units."; var re = new RE2(/\d+/i); var result = str.search(re); eval(t.TEST("result === 9")); re = new RE2("\\b[a-z]+\\b"); result = str.search(re); eval(t.TEST("result === 6")); re = new RE2("\\b\\w+\\b"); result = str.search(re); eval(t.TEST("result === 0")); re = new RE2("z", "gm"); result = str.search(re); eval(t.TEST("result === -1")); }, function test_replace_symbol (t) { "use strict"; if (typeof Symbol == 'undefined' || !Symbol.replace) return; var re = new RE2(/apples/gi); var result = "Apples are round, and apples are juicy.".replace(re, "oranges"); eval(t.TEST("result === 'oranges are round, and oranges are juicy.'")); re = new RE2(/xmas/i); result = "Twas the night before Xmas...".replace(re, "Christmas"); eval(t.TEST("result === 'Twas the night before Christmas...'")); re = new RE2(/(\w+)\s(\w+)/); result = "John Smith".replace(re, "$2, $1"); eval(t.TEST("result === 'Smith, John'")); }, function test_split(t) { "use strict"; if (typeof Symbol == 'undefined' || !Symbol.split) return; var re = new RE2(/\s+/); var result = "Oh brave new world that has such people in it.".split(re); eval(t.TEST("t.unify(result, ['Oh', 'brave', 'new', 'world', 'that', 'has', 'such', 'people', 'in', 'it.'])")); re = new RE2(","); result = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(re); eval(t.TEST("t.unify(result, ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'])")); re = new RE2(/\s*;\s*/); result = "Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ".split(re); eval(t.TEST("t.unify(result, ['Harry Trump', 'Fred Barney', 'Helen Rigby', 'Bill Abel', 'Chris Hand '])")); re = new RE2(/\s+/); result = "Hello World. How are you doing?".split(re, 3); eval(t.TEST("t.unify(result, ['Hello', 'World.', 'How'])")); re = new RE2(/(\d)/); result = "Hello 1 word. Sentence number 2.".split(re); eval(t.TEST("t.unify(result, ['Hello ', '1', ' word. Sentence number ', '2', '.'])")); eval(t.TEST("'asdfghjkl'.split(RE2(/[x-z]*/)).reverse().join('') === 'lkjhgfdsa'")); } ]); node-re2-1.20.12/tests/test_test.js000066400000000000000000000127221462511572500170220ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ // These tests are copied from MDN: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test function test_testFromExec(t) { "use strict"; var re = new RE2("quick\\s(brown).+?(jumps)", "i"); eval(t.TEST("re.test('The Quick Brown Fox Jumps Over The Lazy Dog')")); eval(t.TEST("re.test('tHE qUICK bROWN fOX jUMPS oVER tHE lAZY dOG')")); eval(t.TEST("re.test('the quick brown fox jumps over the lazy dog')")); eval(t.TEST("re.test('THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG')")); eval(t.TEST("!re.test('THE KWIK BROWN FOX JUMPS OVER THE LAZY DOG')")); re = new RE2("ab*", "g"); eval(t.TEST("re.test('abbcdefabh')")); eval(t.TEST("!re.test('qwerty')")); re = new RE2("(hello \\S+)"); eval(t.TEST("re.test('This is a hello world!')")); eval(t.TEST("!re.test('This is a Hello world!')")); }, function test_testSucc(t) { "use strict"; var str = "abbcdefabh"; var re = new RE2("ab*", "g"); var result = re.test(str); eval(t.TEST("result")); eval(t.TEST("re.lastIndex === 3")); result = re.test(str); eval(t.TEST("result")); eval(t.TEST("re.lastIndex === 9")); result = re.test(str); eval(t.TEST("!result")); }, function test_testSimple(t) { "use strict"; var str = "abbcdefabh"; var re1 = new RE2("ab*", "g"); eval(t.TEST("re1.test(str)")); var re2 = new RE2("ab*"); eval(t.TEST("re2.test(str)")); var re3 = new RE2("abc"); eval(t.TEST("!re3.test(str)")); }, function test_testAnchoredToBeginning(t) { "use strict"; var re = RE2('^hello', 'g'); eval(t.TEST("re.test('hellohello')")); eval(t.TEST("!re.test('hellohello')")); }, function test_testInvalid(t) { "use strict"; var re = RE2(''); try { re.test({ toString() { throw "corner"; } }); t.test(false); // shouldn't be here } catch(e) { eval(t.TEST("e === 'corner'")); } }, function test_testAnchor1(t) { "use strict"; var re = new RE2("b|^a", "g"); var result = re.test("aabc"); eval(t.TEST("result")); eval(t.TEST("re.lastIndex === 1")); result = re.test("aabc"); eval(t.TEST("result")); eval(t.TEST("re.lastIndex === 3")); result = re.test("aabc"); eval(t.TEST("!result")); }, function test_testAnchor2(t) { "use strict"; var re = new RE2("(?:^a)", "g"); var result = re.test("aabc"); eval(t.TEST("result")); eval(t.TEST("re.lastIndex === 1")); result = re.test("aabc"); eval(t.TEST("!result")); }, // Unicode tests function test_testUnicode(t) { "use strict"; var re = new RE2("охотник\\s(желает).+?(где)", "i"); eval(t.TEST("re.test('Каждый Охотник Желает Знать Где Сидит Фазан')")); eval(t.TEST("re.test('кАЖДЫЙ оХОТНИК жЕЛАЕТ зНАТЬ гДЕ сИДИТ фАЗАН')")); eval(t.TEST("re.test('каждый охотник желает знать где сидит фазан')")); eval(t.TEST("re.test('КАЖДЫЙ ОХОТНИК ЖЕЛАЕТ ЗНАТЬ ГДЕ СИДИТ ФАЗАН')")); eval(t.TEST("!re.test('Кажный Стрелок Хочет Найти Иде Прячется Птица')")); re = new RE2("аб*", "g"); eval(t.TEST("re.test('аббвгдеабё')")); eval(t.TEST("!re.test('йцукен')")); re = new RE2("(привет \\S+)"); eval(t.TEST("re.test('Это просто привет всем.')")); eval(t.TEST("!re.test('Это просто Привет всем.')")); }, function test_testUnicodeSubsequent(t) { "use strict"; var str = "аббвгдеабё"; var re = new RE2("аб*", "g"); var result = re.test(str); eval(t.TEST("result")); eval(t.TEST("re.lastIndex === 3")); result = re.test(str); eval(t.TEST("result")); eval(t.TEST("re.lastIndex === 9")); result = re.test(str); eval(t.TEST("!result")); }, // Buffer tests function test_testBuffer(t) { "use strict"; var re = new RE2("охотник\\s(желает).+?(где)", "i"); eval(t.TEST("re.test(new Buffer('Каждый Охотник Желает Знать Где Сидит Фазан'))")); eval(t.TEST("re.test(new Buffer('кАЖДЫЙ оХОТНИК жЕЛАЕТ зНАТЬ гДЕ сИДИТ фАЗАН'))")); eval(t.TEST("re.test(new Buffer('каждый охотник желает знать где сидит фазан'))")); eval(t.TEST("re.test(new Buffer('КАЖДЫЙ ОХОТНИК ЖЕЛАЕТ ЗНАТЬ ГДЕ СИДИТ ФАЗАН'))")); eval(t.TEST("!re.test(new Buffer('Кажный Стрелок Хочет Найти Иде Прячется Птица'))")); re = new RE2("аб*", "g"); eval(t.TEST("re.test(new Buffer('аббвгдеабё'))")); eval(t.TEST("!re.test(new Buffer('йцукен'))")); re = new RE2("(привет \\S+)"); eval(t.TEST("re.test(new Buffer('Это просто привет всем.'))")); eval(t.TEST("!re.test(new Buffer('Это просто Привет всем.'))")); }, // Sticky tests function test_testSticky(t) { "use strict"; var re = new RE2("\\s+", "y"); eval(t.TEST("!re.test('Hello world, how are you?')")); re.lastIndex = 5; eval(t.TEST("re.test('Hello world, how are you?')")); eval(t.TEST("re.lastIndex === 6")); var re2 = new RE2("\\s+", "gy"); eval(t.TEST("!re2.test('Hello world, how are you?')")); re2.lastIndex = 5; eval(t.TEST("re2.test('Hello world, how are you?')")); eval(t.TEST("re2.lastIndex === 6")); } ]); node-re2-1.20.12/tests/test_toString.js000066400000000000000000000020721462511572500176510ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); var RE2 = require("../re2"); // tests unit.add(module, [ function test_toString(t) { "use strict"; eval(t.TEST("RE2('').toString() === '/(?:)/u'")); eval(t.TEST("RE2('a').toString() === '/a/u'")); eval(t.TEST("RE2('b', 'i').toString() === '/b/iu'")); eval(t.TEST("RE2('c', 'g').toString() === '/c/gu'")); eval(t.TEST("RE2('d', 'm').toString() === '/d/mu'")); eval(t.TEST("RE2('\\\\d+', 'gi') + '' === '/\\\\d+/giu'")); eval(t.TEST("RE2('\\\\s*', 'gm') + '' === '/\\\\s*/gmu'")); eval(t.TEST("RE2('\\\\S{1,3}', 'ig') + '' === '/\\\\S{1,3}/giu'")); eval(t.TEST("RE2('\\\\D{,2}', 'mig') + '' === '/\\\\D{,2}/gimu'")); eval(t.TEST("RE2('^a{2,}', 'mi') + '' === '/^a{2,}/imu'")); eval(t.TEST("RE2('^a{5}$', 'gim') + '' === '/^a{5}$/gimu'")); eval(t.TEST("RE2('\\\\u{1F603}/', 'iy') + '' === '/\\\\u{1F603}\\\\//iuy'")); eval(t.TEST("RE2('^a{2,}', 'smi') + '' === '/^a{2,}/imsu'")); eval(t.TEST("RE2('c', 'ug').toString() === '/c/gu'")); eval(t.TEST("RE2('d', 'um').toString() === '/d/mu'")); } ]); node-re2-1.20.12/tests/tests.js000066400000000000000000000007071462511572500161460ustar00rootroot00000000000000"use strict"; var unit = require("heya-unit"); require("./test_general"); require("./test_source"); require("./test_exec"); require("./test_test"); require("./test_toString"); require("./test_match"); require("./test_matchAll"); require("./test_replace"); require("./test_search"); require("./test_split"); require("./test_invalid"); require("./test_symbols"); require("./test_prototype"); require("./test_new"); require("./test_groups"); unit.run(); node-re2-1.20.12/tests/worker.js000066400000000000000000000013621462511572500163130ustar00rootroot00000000000000'use strict'; const {Worker, isMainThread} = require('worker_threads'); const RE2 = require('../re2'); if (isMainThread) { // This re-loads the current file inside a Worker instance. console.log('Inside Master!'); const worker = new Worker(__filename); worker.on('exit', code => { console.log('Exit code:', code); test('#2'); }); test('#1'); } else { console.log('Inside Worker!'); test(); } function test(msg) { msg && console.log(isMainThread ? 'Main' : 'Worker', msg); const a = new RE2('^\\d+$'); console.log(isMainThread, a.test('123'), a.test('abc'), a.test('123abc'), a instanceof RE2); const b = RE2('^\\d+$'); console.log(isMainThread, b.test('123'), b.test('abc'), b.test('123abc'), b instanceof RE2); } node-re2-1.20.12/ts-tests/000077500000000000000000000000001462511572500150665ustar00rootroot00000000000000node-re2-1.20.12/ts-tests/test-types.ts000066400000000000000000000015271462511572500175640ustar00rootroot00000000000000import RE2 from 're2'; function assertType(_val: T) {} function test_execTypes() { const re = new RE2('quick\\s(brown).+?(?jumps)', 'ig'); const result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog') if (!(result && result.groups)) { throw 'Unexpected Result' } assertType(result.index) assertType(result.input) assertType(result.groups['verb']) } function test_matchTypes() { const re = new RE2('quick\\s(brown).+?(?jumps)', 'ig'); const result = re.match('The Quick Brown Fox Jumps Over The Lazy Dog') if (!(result && result.index && result.input && result.groups)) { throw 'Unexpected Result' } assertType(result.index) assertType(result.input) assertType(result.groups['verb']) } test_execTypes() test_matchTypes() node-re2-1.20.12/tsconfig.json000066400000000000000000000011141462511572500160040ustar00rootroot00000000000000{ "compilerOptions": { "noEmit": true, "declaration": true, "esModuleInterop": true, "strict": true, "allowUnusedLabels": false, "allowUnreachableCode": false, "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true, "noImplicitOverride": true, "noImplicitReturns": true, "noPropertyAccessFromIndexSignature": true, "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "noUnusedParameters": true, "forceConsistentCasingInFileNames": true }, "include": ["**/*.ts"], "exclude": ["vendor/re2/app/**"] } node-re2-1.20.12/vendor/000077500000000000000000000000001462511572500145755ustar00rootroot00000000000000node-re2-1.20.12/vendor/abseil-cpp/000077500000000000000000000000001462511572500166145ustar00rootroot00000000000000node-re2-1.20.12/vendor/re2/000077500000000000000000000000001462511572500152655ustar00rootroot00000000000000