Compare commits

...

36 Commits

Author SHA1 Message Date
Angela P Wen
aca0f6dc5d Log disk info before/after setup-swift 2023-08-03 11:50:54 +02:00
Florin Coada
2192e3432b Merge pull request #1809 from github/igfoo/code_scanning_codeql_java_lombok
Add support for the code_scanning_codeql_java_lombok feature flag
2023-08-02 12:47:52 +01:00
Angela P Wen
1b6e91df31 Autogenerate source map 2023-08-02 11:54:32 +02:00
Angela P Wen
c32aadf8fd Merge branch 'main' into igfoo/code_scanning_codeql_java_lombok 2023-08-02 02:44:05 -07:00
Angela P Wen
7d646d3301 Empty commit 2023-08-02 11:40:37 +02:00
Henry Mercer
7b79062de0 Merge pull request #1820 from github/henrymercer/delete-bundle-archive
Clean up the bundle archive after extracting it
2023-08-01 20:16:50 +01:00
Henry Mercer
61cdd2503b Factor out common code for cleaning up bundle artifacts 2023-08-01 19:47:57 +01:00
Henry Mercer
92c848eb82 Improve variable naming 2023-08-01 19:21:17 +01:00
Henry Mercer
f93fb8df6e Clean up non-toolcached bundle 2023-08-01 18:50:45 +01:00
Henry Mercer
ea47b2ae40 Add changelog note 2023-08-01 17:54:33 +01:00
Henry Mercer
38adb40e7a Delete bundle archive after extracting it 2023-08-01 17:49:21 +01:00
dependabot[bot]
e7e35baaf0 Bump the npm group with 2 updates (#1819)
* Bump the npm group with 2 updates

Bumps the npm group with 2 updates: [eslint](https://github.com/eslint/eslint) and [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import).


Updates `eslint` from 8.45.0 to 8.46.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.45.0...v8.46.0)

Updates `eslint-plugin-import` from 2.27.5 to 2.28.0
- [Release notes](https://github.com/import-js/eslint-plugin-import/releases)
- [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-plugin-import/compare/v2.27.5...v2.28.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
- dependency-name: eslint-plugin-import
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update checked-in dependencies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-01 03:35:02 -07:00
Nick Rolfe
a6b0ced86b Merge pull request #1818 from github/nickrolfe/disable-intra-layer-parallelism
Pass explicit option to disable intra-layer parallelism
2023-07-31 12:15:52 +01:00
Henry Mercer
6a17359b95 Merge pull request #1816 from github/henrymercer/more-user-errors
Categorize more user errors correctly in telemetry
2023-07-31 11:56:57 +01:00
Henry Mercer
245422d4c0 Merge pull request #1815 from github/henrymercer/update-readme
Simplify README to recommend default setup and refer to docs
2023-07-31 11:56:04 +01:00
Nick Rolfe
c7b7456c9e Pass explicit option to disable intra-layer parallelism 2023-07-31 11:47:25 +01:00
Nick Rolfe
cf445f7cf3 Merge pull request #1817 from github/nickrolfe/evaluator-intra-layer-parallelism-ff
Use feature flag to enable evaluator intra-layer parallelism
2023-07-31 11:03:26 +01:00
Nick Rolfe
2f8540dd31 Add CHANGELOG entry for intra-layer parallelism rollout 2023-07-31 10:08:17 +01:00
Nick Rolfe
bc068d74aa Use feature flag to enable evaluator intra-layer parallelism 2023-07-31 09:44:35 +01:00
Henry Mercer
bcfe48982e Improve function name 2023-07-28 18:51:43 +01:00
Henry Mercer
79690d4663 Make submitting advanced analysis when default setup on a user error 2023-07-28 18:21:38 +01:00
Henry Mercer
5691205077 Make not specifying a required input a user error 2023-07-28 18:18:27 +01:00
Henry Mercer
d9d3212c79 Simplify README to recommend default setup and refer to docs 2023-07-28 17:30:34 +01:00
Henry Mercer
81ae676e79 Merge pull request #1812 from github/henrymercer/no-loc-baseline-for-new-summary
Don't print the lines of code baseline when new analysis summary enabled
2023-07-28 17:18:54 +01:00
Alexander Eyers-Taylor
c8b21b59d1 Merge pull request #1814 from github/mergeback/v2.21.2-to-main-0ba42444
Mergeback v2.21.2 refs/heads/releases/v2 into main
2023-07-28 16:09:27 +01:00
github-actions[bot]
7c2bd355f3 Update checked-in dependencies 2023-07-28 14:10:21 +00:00
github-actions[bot]
868eec5e6d Update changelog and version after v2.21.2 2023-07-28 14:07:45 +00:00
Ian Lynagh
eea148f0e6 Run "npm run build" 2023-07-28 14:56:05 +01:00
Ian Lynagh
34090feb56 Lombok: Only do anything if Java is being analysed 2023-07-28 14:55:23 +01:00
Henry Mercer
67e62e7b01 Don't print the lines of code baseline when new analysis summary enabled 2023-07-28 14:03:02 +01:00
Ian Lynagh
976ada262f Regen 2023-07-27 12:45:19 +01:00
Ian Lynagh
c946707707 Pass codeql in to check 2023-07-27 12:45:08 +01:00
Ian Lynagh
4f6104c444 Run "npm run build" 2023-07-27 12:37:40 +01:00
Ian Lynagh
a27d3e9355 Fix lint suggestions 2023-07-27 12:36:57 +01:00
Ian Lynagh
cae6b78afc Be more consistent 2023-07-27 12:30:08 +01:00
Ian Lynagh
097823f389 Add support for the code_scanning_codeql_java_lombok feature flag 2023-07-27 12:19:38 +01:00
1432 changed files with 27466 additions and 10103 deletions

View File

@@ -35,8 +35,19 @@ runs:
fi
fi
echo "version=$VERSION" | tee -a $GITHUB_OUTPUT
- name: Log disk info on Linux prior to setup-swift
shell: bash
run: |-
if ! hash sudo &> /dev/null; then apt-get update -q=2 && apt-get install sudo -y -q=2; fi;
sudo df -h
if: runner.os == 'Linux'
- uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf # Please update the corresponding SHA in the CLI's CodeQL Action Integration Test.
if: runner.os != 'Windows' && steps.get_swift_version.outputs.version != 'null'
with:
swift-version: "${{ steps.get_swift_version.outputs.version }}"
- name: Log disk info on Linux after setup-swift
shell: bash
run: |-
if ! hash sudo &> /dev/null; then apt-get update -q=2 && apt-get install sudo -y -q=2; fi;
sudo df -h
if: runner.os == 'Linux'

View File

@@ -2,6 +2,11 @@
See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
## [UNRELEASED]
- We are rolling out a feature in August 2023 that will improve multi-threaded performance on larger runners. [#1817](https://github.com/github/codeql-action/pull/1817)
- Reduce disk space usage when downloading the CodeQL bundle. [#1820](https://github.com/github/codeql-action/pull/1820)
## 2.21.2 - 28 Jul 2023
- Update default CodeQL bundle version to 2.14.1. [#1797](https://github.com/github/codeql-action/pull/1797)

157
README.md
View File

@@ -1,6 +1,6 @@
# CodeQL Action
This action runs GitHub's industry-leading semantic code analysis engine, [CodeQL](https://codeql.github.com/), against a repository's source code to find security vulnerabilities. It then automatically uploads the results to GitHub so they can be displayed in the repository's security tab. CodeQL runs an extensible set of [queries](https://github.com/github/codeql), which have been developed by the community and the [GitHub Security Lab](https://securitylab.github.com/) to find common vulnerabilities in your code.
This action runs GitHub's industry-leading semantic code analysis engine, [CodeQL](https://codeql.github.com/), against a repository's source code to find security vulnerabilities. It then automatically uploads the results to GitHub so they can be displayed on pull requests and in the repository's security tab. CodeQL runs an extensible set of [queries](https://github.com/github/codeql), which have been developed by the community and the [GitHub Security Lab](https://securitylab.github.com/) to find common vulnerabilities in your code.
For a list of recent changes, see the CodeQL Action's [changelog](CHANGELOG.md).
@@ -12,160 +12,9 @@ The underlying CodeQL CLI, used in this action, is licensed under the [GitHub Co
## Usage
This is a short walkthrough, but for more information read [configuring code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning).
We recommend using default setup to configure CodeQL analysis for your repository. For more information, see "[Configuring default setup for code scanning](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-default-setup-for-code-scanning)."
To get code scanning results from CodeQL analysis on your repo you can use the following workflow as a template:
```yaml
name: "Code Scanning - Action"
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '30 1 * * 0'
jobs:
CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java, ruby
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
```
If you prefer to integrate this within an existing CI workflow, it should end up looking something like this:
```yaml
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go, javascript
# Here is where you build your code
- run: |
make bootstrap
make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
```
### Configuration file
Use the `config-file` parameter of the `init` action to enable the configuration file. The value of `config-file` is the path to the configuration file you want to use. This example loads the configuration file `./.github/codeql/codeql-config.yml`.
```yaml
- uses: github/codeql-action/init@v2
with:
config-file: ./.github/codeql/codeql-config.yml
```
The configuration file can be located in a different repository. This is useful if you want to share the same configuration across multiple repositories. If the configuration file is in a private repository you can also specify an `external-repository-token` option. This should be a personal access token that has read access to any repositories containing referenced config files and queries.
```yaml
- uses: github/codeql-action/init@v2
with:
config-file: owner/repo/codeql-config.yml@branch
external-repository-token: ${{ secrets.EXTERNAL_REPOSITORY_TOKEN }}
```
For information on how to write a configuration file, see "[Using a custom configuration file](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#using-a-custom-configuration-file)."
If you only want to customise the queries used, you can specify them in your workflow instead of creating a config file, using the `queries` property of the `init` action:
```yaml
- uses: github/codeql-action/init@v2
with:
queries: <local-or-remote-query>,<another-query>
```
By default, this will override any queries specified in a config file. If you wish to use both sets of queries, prefix the list of queries in the workflow with `+`:
```yaml
- uses: github/codeql-action/init@v2
with:
queries: +<local-or-remote-query>,<another-query>
```
### Configuration via `config` input
You can alternatively configure CodeQL using the `config` input to the `init` Action. The value of this input must be a YAML string that follows the configuration file format documented at "[Using a custom configuration file](https://aka.ms/code-scanning-docs/config-file)."
#### Example configuration
```yaml
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config: |
disable-default-queries: true
queries:
- uses: security-extended
- uses: security-and-quality
query-filters:
- include:
tags: /cwe-020/
```
#### Sharing configuration across multiple repositories
You can use Actions or environment variables to share configuration across multiple repositories and to modify configuration without needing to edit the workflow file. In the following example, `vars.CODEQL_CONF` is an [Actions configuration variable](https://docs.github.com/en/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows):
```yaml
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config: ${{ vars.CODEQL_CONF }}
```
You can also configure advanced setup for a repository to find security vulnerabilities in your code using a highly customizable code scanning configuration. For more information, see "[Configuring advanced setup for code scanning](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-advanced-setup-for-code-scanning)" and "[Customizing code scanning](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning)."
## Troubleshooting

6
lib/actions-util.js generated
View File

@@ -39,7 +39,11 @@ const pkg = require("../package.json");
* This allows us to get stronger type checking of required/optional inputs.
*/
const getRequiredInput = function (name) {
return core.getInput(name, { required: true });
const value = core.getInput(name);
if (!value) {
throw new util_1.UserError(`Input required and not supplied: ${name}`);
}
return value;
};
exports.getRequiredInput = getRequiredInput;
/**

File diff suppressed because one or more lines are too long

8
lib/analyze.js generated
View File

@@ -232,7 +232,9 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
}
statusReport["event_reports"].push(perQueryAlertCountEventReport);
}
await runPrintLinesOfCode(language);
if (!(await features.getValue(feature_flags_1.Feature.NewAnalysisSummaryEnabled, codeql))) {
await runPrintLinesOfCode(language);
}
}
catch (e) {
logger.info(String(e));
@@ -283,7 +285,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
fs.writeFileSync(querySuitePath, querySuiteContents);
logger.debug(`Query suite file for ${language}-${type}...\n${querySuiteContents}`);
}
await codeql.databaseRunQueries(databasePath, searchPath, querySuitePath, queryFlags, optimizeForLastQueryRun);
await codeql.databaseRunQueries(databasePath, searchPath, querySuitePath, queryFlags, optimizeForLastQueryRun, features);
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
return querySuitePath;
}
@@ -297,7 +299,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
const querySuitePath = `${databasePath}-queries-${type}.qls`;
fs.writeFileSync(querySuitePath, yaml.dump(querySuite));
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
await codeql.databaseRunQueries(databasePath, undefined, querySuitePath, queryFlags, optimizeForLastQueryRun);
await codeql.databaseRunQueries(databasePath, undefined, querySuitePath, queryFlags, optimizeForLastQueryRun, features);
return querySuitePath;
}
}

File diff suppressed because one or more lines are too long

8
lib/codeql.js generated
View File

@@ -419,7 +419,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
throw new Error(`Unexpected output from codeql resolve build-environment: ${e} in\n${output}`);
}
},
async databaseRunQueries(databasePath, extraSearchPath, querySuitePath, flags, optimizeForLastQueryRun) {
async databaseRunQueries(databasePath, extraSearchPath, querySuitePath, flags, optimizeForLastQueryRun, features) {
const codeqlArgs = [
"database",
"run-queries",
@@ -439,6 +439,12 @@ async function getCodeQLForCmd(cmd, checkVersion) {
if (querySuitePath) {
codeqlArgs.push(querySuitePath);
}
if (await features.getValue(feature_flags_1.Feature.EvaluatorIntraLayerParallelismEnabled, this)) {
codeqlArgs.push("--intra-layer-parallelism");
}
else if (await util.codeQlVersionAbove(this, feature_flags_1.CODEQL_VERSION_INTRA_LAYER_PARALLELISM)) {
codeqlArgs.push("--no-intra-layer-parallelism");
}
await runTool(cmd, codeqlArgs);
},
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId, config, features, logger) {

File diff suppressed because one or more lines are too long

18
lib/feature-flags.js generated
View File

@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.Features = exports.FEATURE_FLAGS_FILE_NAME = exports.featureConfig = exports.Feature = exports.CODEQL_VERSION_NEW_ANALYSIS_SUMMARY = exports.CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = void 0;
exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.Features = exports.FEATURE_FLAGS_FILE_NAME = exports.featureConfig = exports.Feature = exports.CODEQL_VERSION_INTRA_LAYER_PARALLELISM = exports.CODEQL_VERSION_NEW_ANALYSIS_SUMMARY = exports.CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
@@ -40,6 +40,10 @@ exports.CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = "2.13.4";
* Versions 2.14.0+ of the CodeQL CLI support new analysis summaries.
*/
exports.CODEQL_VERSION_NEW_ANALYSIS_SUMMARY = "2.14.0";
/**
* Versions 2.14.0+ of the CodeQL CLI support intra-layer parallelism (aka fine-grained parallelism) options.
*/
exports.CODEQL_VERSION_INTRA_LAYER_PARALLELISM = "2.14.0";
/**
* Feature enablement as returned by the GitHub API endpoint.
*
@@ -48,8 +52,10 @@ exports.CODEQL_VERSION_NEW_ANALYSIS_SUMMARY = "2.14.0";
var Feature;
(function (Feature) {
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
Feature["CodeqlJavaLombokEnabled"] = "codeql_java_lombok_enabled";
Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled";
Feature["DisablePythonDependencyInstallationEnabled"] = "disable_python_dependency_installation_enabled";
Feature["EvaluatorIntraLayerParallelismEnabled"] = "evaluator_intra_layer_parallelism_enabled";
Feature["ExportDiagnosticsEnabled"] = "export_diagnostics_enabled";
Feature["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
Feature["NewAnalysisSummaryEnabled"] = "new_analysis_summary_enabled";
@@ -58,6 +64,11 @@ var Feature;
Feature["UploadFailedSarifEnabled"] = "upload_failed_sarif_enabled";
})(Feature || (exports.Feature = Feature = {}));
exports.featureConfig = {
[Feature.CodeqlJavaLombokEnabled]: {
envVar: "CODEQL_JAVA_LOMBOK",
minimumVersion: "2.14.0",
defaultValue: false,
},
[Feature.DisableKotlinAnalysisEnabled]: {
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
minimumVersion: undefined,
@@ -68,6 +79,11 @@ exports.featureConfig = {
minimumVersion: "2.11.6",
defaultValue: true,
},
[Feature.EvaluatorIntraLayerParallelismEnabled]: {
envVar: "CODEQL_EVALUATOR_INTRA_LAYER_PARALLELISM",
minimumVersion: exports.CODEQL_VERSION_INTRA_LAYER_PARALLELISM,
defaultValue: false,
},
[Feature.ExportDiagnosticsEnabled]: {
envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS",
minimumVersion: "2.12.4",

File diff suppressed because one or more lines are too long

10
lib/init-action.js generated
View File

@@ -178,6 +178,16 @@ async function run() {
if (await features.getValue(feature_flags_1.Feature.DisableKotlinAnalysisEnabled)) {
core.exportVariable("CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN", "true");
}
if (config.languages.includes(languages_1.Language.java)) {
if (await features.getValue(feature_flags_1.Feature.CodeqlJavaLombokEnabled, codeql)) {
logger.info("Enabling CodeQL Java Lombok support");
core.exportVariable("CODEQL_EXTRACTOR_JAVA_RUN_ANNOTATION_PROCESSORS", "true");
}
else {
logger.info("Disabling CodeQL Java Lombok support");
core.exportVariable("CODEQL_EXTRACTOR_JAVA_RUN_ANNOTATION_PROCESSORS", "false");
}
}
// Disable Python dependency extraction if feature flag set
if (await features.getValue(feature_flags_1.Feature.DisablePythonDependencyInstallationEnabled, codeql)) {
core.exportVariable("CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION", "true");

File diff suppressed because one or more lines are too long

40
lib/setup-codeql.js generated
View File

@@ -31,6 +31,7 @@ const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const perf_hooks_1 = require("perf_hooks");
const toolcache = __importStar(require("@actions/tool-cache"));
const del_1 = __importDefault(require("del"));
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
const semver = __importStar(require("semver"));
const uuid_1 = require("uuid");
@@ -420,17 +421,22 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
const dest = path.join(tempDir, (0, uuid_1.v4)());
const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers);
const toolsDownloadStart = perf_hooks_1.performance.now();
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders);
const archivedBundlePath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders);
const toolsDownloadDurationMs = Math.round(perf_hooks_1.performance.now() - toolsDownloadStart);
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
logger.debug(`Finished downloading CodeQL bundle to ${archivedBundlePath} (${toolsDownloadDurationMs} ms).`);
logger.debug("Extracting CodeQL bundle.");
const extractionStart = perf_hooks_1.performance.now();
const extractedBundlePath = await toolcache.extractTar(archivedBundlePath);
const extractionMs = Math.round(perf_hooks_1.performance.now() - extractionStart);
logger.debug(`Finished extracting CodeQL bundle to ${extractedBundlePath} (${extractionMs} ms).`);
await cleanUpGlob(archivedBundlePath, "CodeQL bundle archive", logger);
const bundleVersion = maybeBundleVersion ?? tryGetBundleVersionFromUrl(codeqlURL, logger);
if (bundleVersion === undefined) {
logger.debug("Could not cache CodeQL tools because we could not determine the bundle version from the " +
`URL ${codeqlURL}.`);
return {
toolsVersion: maybeCliVersion ?? "unknown",
codeqlFolder: codeqlExtracted,
codeqlFolder: extractedBundlePath,
toolsDownloadDurationMs,
};
}
@@ -452,9 +458,15 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
const toolcacheVersion = maybeCliVersion?.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)
? `${maybeCliVersion}-${bundleVersion}`
: convertToSemVer(bundleVersion, logger);
logger.debug("Caching CodeQL bundle.");
const toolcachedBundlePath = await toolcache.cacheDir(extractedBundlePath, "CodeQL", toolcacheVersion);
// Defensive check: we expect `cacheDir` to copy the bundle to a new location.
if (toolcachedBundlePath !== extractedBundlePath) {
await cleanUpGlob(extractedBundlePath, "CodeQL bundle from temporary directory", logger);
}
return {
toolsVersion: maybeCliVersion ?? toolcacheVersion,
codeqlFolder: await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion),
codeqlFolder: toolcachedBundlePath,
toolsDownloadDurationMs,
};
}
@@ -510,4 +522,22 @@ async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defau
return { codeqlFolder, toolsDownloadDurationMs, toolsSource, toolsVersion };
}
exports.setupCodeQLBundle = setupCodeQLBundle;
async function cleanUpGlob(glob, name, logger) {
logger.debug(`Cleaning up ${name}.`);
try {
const deletedPaths = await (0, del_1.default)(glob, { force: true });
if (deletedPaths.length === 0) {
logger.warning(`Failed to clean up ${name}: no files found matching ${glob}.`);
}
else if (deletedPaths.length === 1) {
logger.debug(`Cleaned up ${name}.`);
}
else {
logger.debug(`Cleaned up ${name} (${deletedPaths.length} files).`);
}
}
catch (e) {
logger.warning(`Failed to clean up ${name}: ${e}.`);
}
}
//# sourceMappingURL=setup-codeql.js.map

File diff suppressed because one or more lines are too long

13
lib/upload-lib.js generated
View File

@@ -331,7 +331,10 @@ async function waitForProcessing(repositoryNwo, sarifID, logger, options = {
break;
}
else if (status === "failed") {
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
const message = `Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`;
throw shouldConsiderAsUserError(response.data.errors)
? new util_1.UserError(message)
: new Error(message);
}
else {
util.assertNever(status);
@@ -346,6 +349,14 @@ async function waitForProcessing(repositoryNwo, sarifID, logger, options = {
}
}
exports.waitForProcessing = waitForProcessing;
/**
* Returns whether the provided processing errors should be considered a user error.
*/
function shouldConsiderAsUserError(processingErrors) {
return (processingErrors.length === 1 &&
processingErrors[0] ===
"CodeQL analyses from advanced configurations cannot be processed when the default setup is enabled");
}
/**
* Checks the processing result for an unsuccessful execution. Throws if the
* result is not a failure with a single "unsuccessful execution" error.

File diff suppressed because one or more lines are too long

402
node_modules/.package-lock.json generated vendored
View File

@@ -1,6 +1,6 @@
{
"name": "codeql",
"version": "2.21.2",
"version": "2.21.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
@@ -416,18 +416,18 @@
}
},
"node_modules/@eslint-community/regexpp": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz",
"integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==",
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.2.tgz",
"integrity": "sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==",
"dev": true,
"engines": {
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
}
},
"node_modules/@eslint/eslintrc": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.0.tgz",
"integrity": "sha512-Lj7DECXqIVCqnqjjHMPna4vn6GJcMgul/wuS0je9OZ9gsL0zzDpKPVtcG1HaDVc+9y+qgXneTeUMbCqXJNpH1A==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.1.tgz",
"integrity": "sha512-9t7ZA7NGGK8ckelF0PQCfcxIUzs1Md5rrO6U/c+FIQNanea5UZC0wqKXH4vHBccmu4ZJgZ2idtPeW7+Q2npOEA==",
"dev": true,
"dependencies": {
"ajv": "^6.12.4",
@@ -448,9 +448,9 @@
}
},
"node_modules/@eslint/js": {
"version": "8.44.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.44.0.tgz",
"integrity": "sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==",
"version": "8.46.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.46.0.tgz",
"integrity": "sha512-a8TLtmPi8xzPkCbp/OGFUo5yhRkHM2Ko9kOWP4znJr0WAhWyThaw3PnwX4vOTWOAMsV2uRt32PPDcEz63esSaA==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -1252,6 +1252,19 @@
"dequal": "^2.0.3"
}
},
"node_modules/array-buffer-byte-length": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz",
"integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"is-array-buffer": "^3.0.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/array-find-index": {
"version": "1.0.2",
"integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=",
@@ -1286,6 +1299,25 @@
"node": ">=8"
}
},
"node_modules/array.prototype.findlastindex": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.2.tgz",
"integrity": "sha512-tb5thFFlUcp7NdNF6/MpDk/1r/4awWG1FIz3YqDf+/zJSTezBb+/5WViH41obXULHVpDzoiCLpJ/ZO9YbJMsdw==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"es-shim-unscopables": "^1.0.0",
"get-intrinsic": "^1.1.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/array.prototype.flat": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz",
@@ -1322,6 +1354,26 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/arraybuffer.prototype.slice": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.1.tgz",
"integrity": "sha512-09x0ZWFEjj4WD8PDbykUwo3t9arLn8NIzmmYEJFpYekOAQjpkGSyrQhNoRTcwwcFRu+ycWF78QZ63oWTqSjBcw==",
"dev": true,
"dependencies": {
"array-buffer-byte-length": "^1.0.0",
"call-bind": "^1.0.2",
"define-properties": "^1.2.0",
"get-intrinsic": "^1.2.1",
"is-array-buffer": "^3.0.2",
"is-shared-array-buffer": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/arrgv": {
"version": "1.0.2",
"integrity": "sha512-a4eg4yhp7mmruZDQFqVMlxNRFGi/i1r87pt8SDHy0/I8PqSXoUTlWZRdAZo0VXgvEARcujbtTk8kiZRi1uDGRw==",
@@ -2096,9 +2148,9 @@
}
},
"node_modules/define-properties": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz",
"integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz",
"integrity": "sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==",
"dev": true,
"dependencies": {
"has-property-descriptors": "^1.0.0",
@@ -2270,18 +2322,19 @@
}
},
"node_modules/es-abstract": {
"version": "1.21.1",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.21.1.tgz",
"integrity": "sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg==",
"version": "1.22.1",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.22.1.tgz",
"integrity": "sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw==",
"dev": true,
"dependencies": {
"array-buffer-byte-length": "^1.0.0",
"arraybuffer.prototype.slice": "^1.0.1",
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"es-set-tostringtag": "^2.0.1",
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"function.prototype.name": "^1.1.5",
"get-intrinsic": "^1.1.3",
"get-intrinsic": "^1.2.1",
"get-symbol-description": "^1.0.0",
"globalthis": "^1.0.3",
"gopd": "^1.0.1",
@@ -2289,8 +2342,8 @@
"has-property-descriptors": "^1.0.0",
"has-proto": "^1.0.1",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.4",
"is-array-buffer": "^3.0.1",
"internal-slot": "^1.0.5",
"is-array-buffer": "^3.0.2",
"is-callable": "^1.2.7",
"is-negative-zero": "^2.0.2",
"is-regex": "^1.1.4",
@@ -2298,16 +2351,21 @@
"is-string": "^1.0.7",
"is-typed-array": "^1.1.10",
"is-weakref": "^1.0.2",
"object-inspect": "^1.12.2",
"object-inspect": "^1.12.3",
"object-keys": "^1.1.1",
"object.assign": "^4.1.4",
"regexp.prototype.flags": "^1.4.3",
"regexp.prototype.flags": "^1.5.0",
"safe-array-concat": "^1.0.0",
"safe-regex-test": "^1.0.0",
"string.prototype.trim": "^1.2.7",
"string.prototype.trimend": "^1.0.6",
"string.prototype.trimstart": "^1.0.6",
"typed-array-buffer": "^1.0.0",
"typed-array-byte-length": "^1.0.0",
"typed-array-byte-offset": "^1.0.0",
"typed-array-length": "^1.0.4",
"unbox-primitive": "^1.0.2",
"which-typed-array": "^1.1.9"
"which-typed-array": "^1.1.10"
},
"engines": {
"node": ">= 0.4"
@@ -2400,27 +2458,27 @@
}
},
"node_modules/eslint": {
"version": "8.45.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.45.0.tgz",
"integrity": "sha512-pd8KSxiQpdYRfYa9Wufvdoct3ZPQQuVuU5O6scNgMuOMYuxvH0IGaYK0wUFjo4UYYQQCUndlXiMbnxopwvvTiw==",
"version": "8.46.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.46.0.tgz",
"integrity": "sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.4.0",
"@eslint/eslintrc": "^2.1.0",
"@eslint/js": "8.44.0",
"@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.1",
"@eslint/js": "^8.46.0",
"@humanwhocodes/config-array": "^0.11.10",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.10.0",
"ajv": "^6.12.4",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.3.2",
"doctrine": "^3.0.0",
"escape-string-regexp": "^4.0.0",
"eslint-scope": "^7.2.0",
"eslint-visitor-keys": "^3.4.1",
"espree": "^9.6.0",
"eslint-scope": "^7.2.2",
"eslint-visitor-keys": "^3.4.2",
"espree": "^9.6.1",
"esquery": "^1.4.2",
"esutils": "^2.0.2",
"fast-deep-equal": "^3.1.3",
@@ -2543,9 +2601,9 @@
}
},
"node_modules/eslint-module-utils": {
"version": "2.7.4",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz",
"integrity": "sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz",
"integrity": "sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==",
"dev": true,
"dependencies": {
"debug": "^3.2.7"
@@ -2653,26 +2711,29 @@
}
},
"node_modules/eslint-plugin-import": {
"version": "2.27.5",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz",
"integrity": "sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==",
"version": "2.28.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.28.0.tgz",
"integrity": "sha512-B8s/n+ZluN7sxj9eUf7/pRFERX0r5bnFA2dCaLHy2ZeaQEAz0k+ZZkFWRFHJAqxfxQDx6KLv9LeIki7cFdwW+Q==",
"dev": true,
"dependencies": {
"array-includes": "^3.1.6",
"array.prototype.findlastindex": "^1.2.2",
"array.prototype.flat": "^1.3.1",
"array.prototype.flatmap": "^1.3.1",
"debug": "^3.2.7",
"doctrine": "^2.1.0",
"eslint-import-resolver-node": "^0.3.7",
"eslint-module-utils": "^2.7.4",
"eslint-module-utils": "^2.8.0",
"has": "^1.0.3",
"is-core-module": "^2.11.0",
"is-core-module": "^2.12.1",
"is-glob": "^4.0.3",
"minimatch": "^3.1.2",
"object.fromentries": "^2.0.6",
"object.groupby": "^1.0.0",
"object.values": "^1.1.6",
"resolve": "^1.22.1",
"semver": "^6.3.0",
"tsconfig-paths": "^3.14.1"
"resolve": "^1.22.3",
"semver": "^6.3.1",
"tsconfig-paths": "^3.14.2"
},
"engines": {
"node": ">=4"
@@ -2690,15 +2751,6 @@
"ms": "^2.1.1"
}
},
"node_modules/eslint-plugin-import/node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"dev": true,
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/eslint-plugin-jsx-a11y": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.7.1.tgz",
@@ -2801,10 +2853,26 @@
"node": ">=4.0.0"
}
},
"node_modules/eslint-scope": {
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz",
"integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==",
"dev": true,
"dependencies": {
"esrecurse": "^4.3.0",
"estraverse": "^5.2.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint-visitor-keys": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz",
"integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==",
"version": "3.4.2",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.2.tgz",
"integrity": "sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -2866,31 +2934,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint/node_modules/eslint-scope": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz",
"integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==",
"dev": true,
"dependencies": {
"esrecurse": "^4.3.0",
"estraverse": "^5.2.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint/node_modules/estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"dev": true,
"engines": {
"node": ">=4.0"
}
},
"node_modules/eslint/node_modules/find-up": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
@@ -3005,9 +3048,9 @@
}
},
"node_modules/espree": {
"version": "9.6.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-9.6.0.tgz",
"integrity": "sha512-1FH/IiruXZ84tpUlm0aCUEwMl2Ho5ilqVh0VvQXw+byAz/4SAciyHLlfmL5WYqsvD38oymdUwBss0LtK8m4s/A==",
"version": "9.6.1",
"resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz",
"integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==",
"dev": true,
"dependencies": {
"acorn": "^8.9.0",
@@ -3046,17 +3089,9 @@
"node": ">=0.10"
}
},
"node_modules/esquery/node_modules/estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"dev": true,
"engines": {
"node": ">=4.0"
}
},
"node_modules/esrecurse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
"integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
"dev": true,
"dependencies": {
@@ -3066,9 +3101,10 @@
"node": ">=4.0"
}
},
"node_modules/esrecurse/node_modules/estraverse": {
"version": "5.2.0",
"integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==",
"node_modules/estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"dev": true,
"engines": {
"node": ">=4.0"
@@ -3360,13 +3396,14 @@
}
},
"node_modules/get-intrinsic": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz",
"integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
"integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
"dev": true,
"dependencies": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-proto": "^1.0.1",
"has-symbols": "^1.0.3"
},
"funding": {
@@ -3652,12 +3689,12 @@
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"node_modules/internal-slot": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.4.tgz",
"integrity": "sha512-tA8URYccNzMo94s5MQZgH8NB/XTa6HsOo0MLfXTKKEnHVVdegzaQoFZ7Jp44bdvLvY2waT5dc+j5ICEswhi7UQ==",
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.5.tgz",
"integrity": "sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==",
"dev": true,
"dependencies": {
"get-intrinsic": "^1.1.3",
"get-intrinsic": "^1.2.0",
"has": "^1.0.3",
"side-channel": "^1.0.4"
},
@@ -3691,13 +3728,13 @@
}
},
"node_modules/is-array-buffer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.1.tgz",
"integrity": "sha512-ASfLknmY8Xa2XtB4wmbz13Wu202baeA18cJBCeCy0wXUHZF0IPyVEXqKEcd+t2fNSLLL1vC6k7lxZEojNbISXQ==",
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz",
"integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"get-intrinsic": "^1.2.0",
"is-typed-array": "^1.1.10"
},
"funding": {
@@ -3757,9 +3794,9 @@
}
},
"node_modules/is-core-module": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
"integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz",
"integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==",
"dev": true,
"dependencies": {
"has": "^1.0.3"
@@ -4421,9 +4458,9 @@
}
},
"node_modules/minimist": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -4644,6 +4681,18 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object.groupby": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.0.tgz",
"integrity": "sha512-70MWG6NfRH9GnbZOikuhPPYzpUpof9iW2J9E4dW7FXTqPNb6rllE6u39SKwwiNh8lCwX3DDb5OgcKGiEBrTTyw==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.2.0",
"es-abstract": "^1.21.2",
"get-intrinsic": "^1.2.1"
}
},
"node_modules/object.values": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz",
@@ -5039,14 +5088,14 @@
"dev": true
},
"node_modules/regexp.prototype.flags": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz",
"integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==",
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz",
"integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"functions-have-names": "^1.2.2"
"define-properties": "^1.2.0",
"functions-have-names": "^1.2.3"
},
"engines": {
"node": ">= 0.4"
@@ -5085,12 +5134,12 @@
}
},
"node_modules/resolve": {
"version": "1.22.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
"integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==",
"version": "1.22.3",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.3.tgz",
"integrity": "sha512-P8ur/gp/AmbEzjr729bZnLjXK5Z+4P0zhIJgBgzqRih7hL7BOukHGtSTA3ACMY467GRFz3duQsi0bDZdR7DKdw==",
"dev": true,
"dependencies": {
"is-core-module": "^2.9.0",
"is-core-module": "^2.12.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
@@ -5297,6 +5346,30 @@
"queue-microtask": "^1.2.2"
}
},
"node_modules/safe-array-concat": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.0.tgz",
"integrity": "sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.2.0",
"has-symbols": "^1.0.3",
"isarray": "^2.0.5"
},
"engines": {
"node": ">=0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/safe-array-concat/node_modules/isarray": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==",
"dev": true
},
"node_modules/safe-regex-test": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz",
@@ -5543,6 +5616,23 @@
"node": ">=8"
}
},
"node_modules/string.prototype.trim": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz",
"integrity": "sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/string.prototype.trimend": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz",
@@ -5819,13 +5909,13 @@
}
},
"node_modules/tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
"integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==",
"version": "3.14.2",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz",
"integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==",
"dev": true,
"dependencies": {
"@types/json5": "^0.0.29",
"json5": "^1.0.1",
"json5": "^1.0.2",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
}
@@ -5875,6 +5965,57 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/typed-array-buffer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz",
"integrity": "sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.2.1",
"is-typed-array": "^1.1.10"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/typed-array-byte-length": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz",
"integrity": "sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"has-proto": "^1.0.1",
"is-typed-array": "^1.1.10"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/typed-array-byte-offset": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz",
"integrity": "sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==",
"dev": true,
"dependencies": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"has-proto": "^1.0.1",
"is-typed-array": "^1.1.10"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/typed-array-length": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz",
@@ -6051,17 +6192,16 @@
}
},
"node_modules/which-typed-array": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz",
"integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==",
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.11.tgz",
"integrity": "sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew==",
"dev": true,
"dependencies": {
"available-typed-arrays": "^1.0.5",
"call-bind": "^1.0.2",
"for-each": "^0.3.3",
"gopd": "^1.0.1",
"has-tostringtag": "^1.0.0",
"is-typed-array": "^1.1.10"
"has-tostringtag": "^1.0.0"
},
"engines": {
"node": ">= 0.4"

View File

@@ -79,7 +79,7 @@ Parse a regular expression literal.
- **Return:**
- The AST of the regular expression.
#### parser.parsePattern(source, start?, end?, uFlag?)
#### parser.parsePattern(source, start?, end?, flags?)
Parse a regular expression pattern.
@@ -87,7 +87,7 @@ Parse a regular expression pattern.
- `source` (`string`) The source code to parse. E.g. `"abc"`.
- `start?` (`number`) The start index in the source code. Default is `0`.
- `end?` (`number`) The end index in the source code. Default is `source.length`.
- `uFlag?` (`boolean`) The flag to enable Unicode mode.
- `flags?` (`{ unicode?: boolean, unicodeSets?: boolean }`) The flags to enable Unicode mode, and Unicode Set mode.
- **Return:**
- The AST of the regular expression pattern.
@@ -118,7 +118,7 @@ Validate a regular expression literal.
- `start?` (`number`) The start index in the source code. Default is `0`.
- `end?` (`number`) The end index in the source code. Default is `source.length`.
#### validator.validatePattern(source, start, end, uFlag)
#### validator.validatePattern(source, start, end, flags)
Validate a regular expression pattern.
@@ -126,7 +126,7 @@ Validate a regular expression pattern.
- `source` (`string`) The source code to validate.
- `start?` (`number`) The start index in the source code. Default is `0`.
- `end?` (`number`) The end index in the source code. Default is `source.length`.
- `uFlag?` (`boolean`) The flag to enable Unicode mode.
- `flags?` (`{ unicode?: boolean, unicodeSets?: boolean }`) The flags to enable Unicode mode, and Unicode Set mode.
#### validator.validateFlags(source, start, end)
@@ -172,6 +172,6 @@ Please use GitHub's Issues/PRs.
- `npm run watch` runs tests with `--watch` option.
[`AST.Node`]: src/ast.ts#L4
[`RegExpParser.Options`]: src/parser.ts#L539
[`RegExpValidator.Options`]: src/validator.ts#L127
[`RegExpVisitor.Handlers`]: src/visitor.ts#L204
[`RegExpParser.Options`]: src/parser.ts#L743
[`RegExpValidator.Options`]: src/validator.ts#L220
[`RegExpVisitor.Handlers`]: src/visitor.ts#L291

View File

@@ -44,11 +44,16 @@ declare module "@eslint-community/regexpp/ast" {
| CapturingGroup
| CharacterClass
| CharacterClassRange
| ClassIntersection
| ClassStringDisjunction
| ClassSubtraction
| ExpressionCharacterClass
| Group
| LookaroundAssertion
| Pattern
| Quantifier
| RegExpLiteral;
| RegExpLiteral
| StringAlternative;
/**
* The type which includes all leaf nodes.
*/
@@ -71,16 +76,28 @@ declare module "@eslint-community/regexpp/ast" {
| Character
| CharacterClass
| CharacterSet
| ExpressionCharacterClass
| Group
| LookaheadAssertion;
/**
* The type which includes all character class atom nodes.
*/
export type CharacterClassElement =
| ClassRangesCharacterClassElement
| UnicodeSetsCharacterClassElement;
export type ClassRangesCharacterClassElement =
| Character
| CharacterClassRange
| EscapeCharacterSet
| UnicodePropertyCharacterSet;
export type UnicodeSetsCharacterClassElement =
| Character
| CharacterClassRange
| ClassStringDisjunction
| EscapeCharacterSet
| ExpressionCharacterClass
| UnicodePropertyCharacterSet
| UnicodeSetsCharacterClass;
/**
* The type which defines common properties for all node types.
*/
@@ -184,12 +201,35 @@ declare module "@eslint-community/regexpp/ast" {
* The character class.
* E.g. `[ab]`, `[^ab]`
*/
export interface CharacterClass extends NodeBase {
export type CharacterClass =
| ClassRangesCharacterClass
| UnicodeSetsCharacterClass;
interface BaseCharacterClass extends NodeBase {
type: "CharacterClass";
parent: Alternative | Quantifier;
parent:
| Alternative
| ExpressionCharacterClass
| Quantifier
| UnicodeSetsCharacterClass;
unicodeSets: boolean;
negate: boolean;
elements: CharacterClassElement[];
}
export interface ClassRangesCharacterClass extends BaseCharacterClass {
parent: Alternative | Quantifier;
unicodeSets: false;
elements: ClassRangesCharacterClassElement[];
}
/** UnicodeSetsCharacterClass is the CharacterClass when in Unicode sets mode. So it may contain strings. */
export interface UnicodeSetsCharacterClass extends BaseCharacterClass {
parent:
| Alternative
| ExpressionCharacterClass
| Quantifier
| UnicodeSetsCharacterClass;
unicodeSets: true;
elements: UnicodeSetsCharacterClassElement[];
}
/**
* The character class.
* E.g. `[a-b]`
@@ -249,7 +289,12 @@ declare module "@eslint-community/regexpp/ast" {
*/
export interface EscapeCharacterSet extends NodeBase {
type: "CharacterSet";
parent: Alternative | CharacterClass | Quantifier;
parent:
| Alternative
| CharacterClass
| ClassIntersection
| ClassSubtraction
| Quantifier;
kind: "digit" | "space" | "word";
negate: boolean;
}
@@ -257,14 +302,92 @@ declare module "@eslint-community/regexpp/ast" {
* The unicode property escape.
* E.g. `\p{ASCII}`, `\P{ASCII}`, `\p{Script=Hiragana}`
*/
export interface UnicodePropertyCharacterSet extends NodeBase {
export type UnicodePropertyCharacterSet =
| CharacterUnicodePropertyCharacterSet
| StringsUnicodePropertyCharacterSet;
interface BaseUnicodePropertyCharacterSet extends NodeBase {
type: "CharacterSet";
parent: Alternative | CharacterClass | Quantifier;
parent:
| Alternative
| CharacterClass
| ClassIntersection
| ClassSubtraction
| Quantifier;
kind: "property";
strings: boolean;
key: string;
value: string | null;
negate: boolean;
}
export interface CharacterUnicodePropertyCharacterSet
extends BaseUnicodePropertyCharacterSet {
strings: false;
value: string | null;
negate: boolean;
}
/** StringsUnicodePropertyCharacterSet is Unicode property escape with property of strings. */
export interface StringsUnicodePropertyCharacterSet
extends BaseUnicodePropertyCharacterSet {
strings: true;
value: null;
negate: false;
}
/**
* The expression character class.
* E.g. `[a--b]`, `[a&&b]`,`[^a--b]`, `[^a&&b]`
*/
export interface ExpressionCharacterClass extends NodeBase {
type: "ExpressionCharacterClass";
parent:
| Alternative
| ExpressionCharacterClass
| Quantifier
| UnicodeSetsCharacterClass;
negate: boolean;
expression: ClassIntersection | ClassSubtraction;
}
export type ClassSetOperand =
| Character
| ClassStringDisjunction
| EscapeCharacterSet
| ExpressionCharacterClass
| UnicodePropertyCharacterSet
| UnicodeSetsCharacterClass;
/**
* The character class intersection.
* E.g. `a&&b`
*/
export interface ClassIntersection extends NodeBase {
type: "ClassIntersection";
parent: ClassIntersection | ExpressionCharacterClass;
left: ClassIntersection | ClassSetOperand;
right: ClassSetOperand;
}
/**
* The character class subtraction.
* E.g. `a--b`
*/
export interface ClassSubtraction extends NodeBase {
type: "ClassSubtraction";
parent: ClassSubtraction | ExpressionCharacterClass;
left: ClassSetOperand | ClassSubtraction;
right: ClassSetOperand;
}
/**
* The character class string disjunction.
* E.g. `\q{a|b}`
*/
export interface ClassStringDisjunction extends NodeBase {
type: "ClassStringDisjunction";
parent: ClassIntersection | ClassSubtraction | UnicodeSetsCharacterClass;
alternatives: StringAlternative[];
}
/** StringAlternative is only used for `\q{alt}`({@link ClassStringDisjunction}). */
export interface StringAlternative extends NodeBase {
type: "StringAlternative";
parent: ClassStringDisjunction;
elements: Character[];
}
/**
* The character.
* This includes escape sequences which mean a character.
@@ -272,7 +395,14 @@ declare module "@eslint-community/regexpp/ast" {
*/
export interface Character extends NodeBase {
type: "Character";
parent: Alternative | CharacterClass | CharacterClassRange | Quantifier;
parent:
| Alternative
| CharacterClass
| CharacterClassRange
| ClassIntersection
| ClassSubtraction
| Quantifier
| StringAlternative;
value: number;
}
/**
@@ -298,7 +428,9 @@ declare module "@eslint-community/regexpp/ast" {
multiline: boolean;
sticky: boolean;
unicode: boolean;
unicodeSets: boolean;
}
export {};
}
declare module "@eslint-community/regexpp/parser" {
@@ -318,13 +450,14 @@ declare module "@eslint-community/regexpp/parser" {
*/
strict?: boolean;
/**
* ECMAScript version. Default is `2023`.
* ECMAScript version. Default is `2024`.
* - `2015` added `u` and `y` flags.
* - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
* and Unicode Property Escape.
* - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
* - `2022` added `d` flag.
* - `2023` added more valid Unicode Property Escapes.
* - `2024` added `v` flag.
*/
ecmaVersion?: EcmaVersion;
}
@@ -356,6 +489,25 @@ declare module "@eslint-community/regexpp/parser" {
* @param source The source code to parse.
* @param start The start index in the source code.
* @param end The end index in the source code.
* @param flags The flags.
* @returns The AST of the given pattern.
*/
parsePattern(
source: string,
start?: number,
end?: number,
flags?: {
unicode?: boolean;
unicodeSets?: boolean;
}
): Pattern;
/**
* @deprecated Backward compatibility
* Use object `flags` instead of boolean `uFlag`.
*
* @param source The source code to parse.
* @param start The start index in the source code.
* @param end The end index in the source code.
* @param uFlag The flag to set unicode mode.
* @returns The AST of the given pattern.
*/
@@ -370,6 +522,12 @@ declare module "@eslint-community/regexpp/parser" {
declare module "@eslint-community/regexpp/validator" {
import type { EcmaVersion } from "@eslint-community/regexpp/ecma-versions";
export type RegExpValidatorSourceContext = {
readonly source: string;
readonly start: number;
readonly end: number;
readonly kind: "flags" | "literal" | "pattern";
};
export namespace RegExpValidator {
/**
* The options for RegExpValidator construction.
@@ -380,13 +538,14 @@ declare module "@eslint-community/regexpp/validator" {
*/
strict?: boolean;
/**
* ECMAScript version. Default is `2023`.
* ECMAScript version. Default is `2024`.
* - `2015` added `u` and `y` flags.
* - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
* and Unicode Property Escape.
* - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
* - `2022` added `d` flag.
* - `2023` added more valid Unicode Property Escapes.
* - `2024` added `v` flag.
*/
ecmaVersion?: EcmaVersion;
/**
@@ -411,6 +570,7 @@ declare module "@eslint-community/regexpp/validator" {
* @param flags.sticky `y` flag.
* @param flags.dotAll `s` flag.
* @param flags.hasIndices `d` flag.
* @param flags.unicodeSets `v` flag.
*/
onRegExpFlags?: (
start: number,
@@ -423,6 +583,7 @@ declare module "@eslint-community/regexpp/validator" {
sticky: boolean;
dotAll: boolean;
hasIndices: boolean;
unicodeSets: boolean;
}
) => void;
/**
@@ -604,6 +765,7 @@ declare module "@eslint-community/regexpp/validator" {
* @param key The property name.
* @param value The property value.
* @param negate The flag which represents that the character set is negative.
* @param strings If true, the given property is property of strings.
*/
onUnicodePropertyCharacterSet?: (
start: number,
@@ -611,7 +773,8 @@ declare module "@eslint-community/regexpp/validator" {
kind: "property",
key: string,
value: string | null,
negate: boolean
negate: boolean,
strings: boolean
) => void;
/**
* A function that is called when the validator found a character.
@@ -635,8 +798,13 @@ declare module "@eslint-community/regexpp/validator" {
* A function that is called when the validator entered a character class.
* @param start The 0-based index of the first character.
* @param negate The flag which represents that the character class is negative.
* @param unicodeSets `true` if unicodeSets mode.
*/
onCharacterClassEnter?: (start: number, negate: boolean) => void;
onCharacterClassEnter?: (
start: number,
negate: boolean,
unicodeSets: boolean
) => void;
/**
* A function that is called when the validator left a character class.
* @param start The 0-based index of the first character.
@@ -661,6 +829,46 @@ declare module "@eslint-community/regexpp/validator" {
min: number,
max: number
) => void;
/**
* A function that is called when the validator found a class intersection.
* @param start The 0-based index of the first character.
* @param end The next 0-based index of the last character.
*/
onClassIntersection?: (start: number, end: number) => void;
/**
* A function that is called when the validator found a class subtraction.
* @param start The 0-based index of the first character.
* @param end The next 0-based index of the last character.
*/
onClassSubtraction?: (start: number, end: number) => void;
/**
* A function that is called when the validator entered a class string disjunction.
* @param start The 0-based index of the first character.
*/
onClassStringDisjunctionEnter?: (start: number) => void;
/**
* A function that is called when the validator left a class string disjunction.
* @param start The 0-based index of the first character.
* @param end The next 0-based index of the last character.
*/
onClassStringDisjunctionLeave?: (start: number, end: number) => void;
/**
* A function that is called when the validator entered a string alternative.
* @param start The 0-based index of the first character.
* @param index The 0-based index of alternatives in a disjunction.
*/
onStringAlternativeEnter?: (start: number, index: number) => void;
/**
* A function that is called when the validator left a string alternative.
* @param start The 0-based index of the first character.
* @param end The next 0-based index of the last character.
* @param index The 0-based index of alternatives in a disjunction.
*/
onStringAlternativeLeave?: (
start: number,
end: number,
index: number
) => void;
}
}
/**
@@ -691,6 +899,23 @@ declare module "@eslint-community/regexpp/validator" {
* @param source The source code to validate.
* @param start The start index in the source code.
* @param end The end index in the source code.
* @param flags The flags.
*/
validatePattern(
source: string,
start?: number,
end?: number,
flags?: {
unicode?: boolean;
unicodeSets?: boolean;
}
): void;
/**
* @deprecated Backward compatibility
* Use object `flags` instead of boolean `uFlag`.
* @param source The source code to validate.
* @param start The start index in the source code.
* @param end The end index in the source code.
* @param uFlag The flag to set unicode mode.
*/
validatePattern(
@@ -712,12 +937,17 @@ declare module "@eslint-community/regexpp/visitor" {
CharacterClass,
CharacterClassRange,
CharacterSet,
ClassIntersection,
ClassStringDisjunction,
ClassSubtraction,
ExpressionCharacterClass,
Flags,
Group,
Node,
Pattern,
Quantifier,
RegExpLiteral,
StringAlternative,
} from "@eslint-community/regexpp/ast";
/**
* The visitor to walk on AST.
@@ -752,6 +982,18 @@ declare module "@eslint-community/regexpp/visitor" {
onCharacterClassRangeLeave?: (node: CharacterClassRange) => void;
onCharacterSetEnter?: (node: CharacterSet) => void;
onCharacterSetLeave?: (node: CharacterSet) => void;
onClassIntersectionEnter?: (node: ClassIntersection) => void;
onClassIntersectionLeave?: (node: ClassIntersection) => void;
onClassStringDisjunctionEnter?: (node: ClassStringDisjunction) => void;
onClassStringDisjunctionLeave?: (node: ClassStringDisjunction) => void;
onClassSubtractionEnter?: (node: ClassSubtraction) => void;
onClassSubtractionLeave?: (node: ClassSubtraction) => void;
onExpressionCharacterClassEnter?: (
node: ExpressionCharacterClass
) => void;
onExpressionCharacterClassLeave?: (
node: ExpressionCharacterClass
) => void;
onFlagsEnter?: (node: Flags) => void;
onFlagsLeave?: (node: Flags) => void;
onGroupEnter?: (node: Group) => void;
@@ -762,6 +1004,8 @@ declare module "@eslint-community/regexpp/visitor" {
onQuantifierLeave?: (node: Quantifier) => void;
onRegExpLiteralEnter?: (node: RegExpLiteral) => void;
onRegExpLiteralLeave?: (node: RegExpLiteral) => void;
onStringAlternativeEnter?: (node: StringAlternative) => void;
onStringAlternativeLeave?: (node: StringAlternative) => void;
}
}
}
@@ -777,5 +1021,7 @@ declare module "@eslint-community/regexpp/ecma-versions" {
| 2020
| 2021
| 2022
| 2023;
| 2023
| 2024;
export const latestEcmaVersion = 2024;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@eslint-community/regexpp",
"version": "4.5.1",
"version": "4.6.2",
"description": "Regular expression parser for ECMAScript.",
"keywords": [
"regexp",
@@ -53,10 +53,12 @@
"clean": "rimraf .temp index.*",
"lint": "eslint . --ext .ts",
"test": "nyc _mocha \"test/*.ts\" --reporter dot --timeout 10000",
"debug": "mocha --require ts-node/register/transpile-only \"test/*.ts\" --reporter dot --timeout 10000",
"update:test": "ts-node scripts/update-fixtures.ts",
"update:unicode": "run-s update:unicode:*",
"update:unicode:ids": "ts-node scripts/update-unicode-ids.ts",
"update:unicode:props": "ts-node scripts/update-unicode-properties.ts",
"update:test262:extract": "ts-node -T scripts/extract-test262.ts",
"preversion": "npm test && npm run -s build",
"postversion": "git push && git push --tags",
"prewatch": "npm run -s clean",
@@ -72,6 +74,7 @@
"@types/node": "^12.20.55",
"dts-bundle": "^0.7.3",
"eslint": "^8.31.0",
"js-tokens": "^8.0.1",
"jsdom": "^19.0.0",
"mocha": "^9.2.2",
"npm-run-all": "^4.1.5",
@@ -79,6 +82,8 @@
"rimraf": "^3.0.2",
"rollup": "^2.79.1",
"rollup-plugin-sourcemaps": "^0.6.3",
"test262": "git+https://github.com/tc39/test262.git",
"test262-stream": "^1.4.0",
"ts-node": "^10.9.1",
"typescript": "~5.0.2"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@eslint/eslintrc",
"version": "2.1.0",
"version": "2.1.1",
"description": "The legacy ESLintRC config file format for ESLint",
"type": "module",
"main": "./dist/eslintrc.cjs",

View File

@@ -1,6 +1,6 @@
{
"name": "@eslint/js",
"version": "8.44.0",
"version": "8.46.0",
"description": "ESLint JavaScript language implementation",
"main": "./src/index.js",
"scripts": {},

View File

@@ -172,7 +172,6 @@ module.exports = Object.freeze({
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",

5
node_modules/array-buffer-byte-length/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"root": true,
"extends": "@ljharb",
}

View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/array-buffer-byte-length
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

13
node_modules/array-buffer-byte-length/.nycrc generated vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"test"
]
}

15
node_modules/array-buffer-byte-length/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,15 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v1.0.0 - 2023-02-28
### Commits
- Initial implementation, tests, readme [`2db6cad`](https://github.com/inspect-js/array-buffer-byte-length/commit/2db6cad79270ab1966f5ea80160abbcd4534c91d)
- Initial commit [`b2a0c9c`](https://github.com/inspect-js/array-buffer-byte-length/commit/b2a0c9c2246514b7999d331aad868c4f32326db7)
- npm init [`376acdb`](https://github.com/inspect-js/array-buffer-byte-length/commit/376acdbd4435cb1d4c31d107cacb3b86f2363aee)
- Only apps should have lockfiles [`70cf325`](https://github.com/inspect-js/array-buffer-byte-length/commit/70cf32526fc727d0d16a12d85a4bddea70075e31)

21
node_modules/array-buffer-byte-length/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Inspect JS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40
node_modules/array-buffer-byte-length/README.md generated vendored Normal file
View File

@@ -0,0 +1,40 @@
# array-buffer-byte-length <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
Get the byte length of an ArrayBuffer, even in engines without a `.byteLength` method.
## Example
```js
const assert = require('assert');
const byteLength = require('array-buffer-byte-length');
assert.equal(byteLength([]), NaN, 'an array is not an ArrayBuffer, yields NaN');
assert.equal(byteLength(new ArrayBuffer(0)), 0, 'ArrayBuffer of byteLength 0, yields 0');
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/array-buffer-byte-length
[npm-version-svg]: https://versionbadg.es/inspect-js/array-buffer-byte-length.svg
[deps-svg]: https://david-dm.org/inspect-js/array-buffer-byte-length.svg
[deps-url]: https://david-dm.org/inspect-js/array-buffer-byte-length
[dev-deps-svg]: https://david-dm.org/inspect-js/array-buffer-byte-length/dev-status.svg
[dev-deps-url]: https://david-dm.org/inspect-js/array-buffer-byte-length#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/array-buffer-byte-length.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/array-buffer-byte-length.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/array-buffer-byte-length.svg
[downloads-url]: https://npm-stat.com/charts.html?package=array-buffer-byte-length
[codecov-image]: https://codecov.io/gh/inspect-js/array-buffer-byte-length/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/inspect-js/array-buffer-byte-length/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/array-buffer-byte-length
[actions-url]: https://github.com/inspect-js/array-buffer-byte-length/actions

13
node_modules/array-buffer-byte-length/index.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
var callBound = require('call-bind/callBound');
var $byteLength = callBound('ArrayBuffer.prototype.byteLength', true);
var isArrayBuffer = require('is-array-buffer');
module.exports = function byteLength(ab) {
if (!isArrayBuffer(ab)) {
return NaN;
}
return $byteLength ? $byteLength(ab) : ab.byteLength;
}; // in node < 0.11, byteLength is an own nonconfigurable property

81
node_modules/array-buffer-byte-length/package.json generated vendored Normal file
View File

@@ -0,0 +1,81 @@
{
"name": "array-buffer-byte-length",
"version": "1.0.0",
"description": "Get the byte length of an ArrayBuffer, even in engines without a `.byteLength` method.",
"main": "index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"pretest": "npm run lint",
"prelint": "evalmd README.md",
"lint": "eslint --ext=js,mjs .",
"tests-only": "nyc tape 'test/**/*.js'",
"test": "npm run tests-only",
"posttest": "aud --production",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"keywords": [
"shim",
"polyfill",
"ArrayBuffer",
"byteLength",
"byte",
"length",
"es-shim API",
"es-shims"
],
"author": "Jordan Harband <ljharb@gmail.com>",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/inspect-js/array-buffer-byte-length.git"
},
"bugs": {
"url": "https://github.com/inspect-js/array-buffer-byte-length/issues"
},
"homepage": "https://github.com/inspect-js/array-buffer-byte-length#readme",
"dependencies": {
"call-bind": "^1.0.2",
"is-array-buffer": "^3.0.1"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.0.1",
"aud": "^2.0.2",
"auto-changelog": "^2.4.0",
"es-value-fixtures": "^1.4.2",
"eslint": "=8.8.0",
"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"in-publish": "^2.0.1",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"object-inspect": "^1.12.3",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.3"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"testling": {
"files": "test/index.js"
},
"publishConfig": {
"ignore": [
".github/workflows"
]
}
}

26
node_modules/array-buffer-byte-length/test/index.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
'use strict';
var test = require('tape');
var forEach = require('for-each');
var v = require('es-value-fixtures');
var inspect = require('object-inspect');
var byteLength = require('../');
test('byteLength', function (t) {
forEach(v.objects.concat(v.primitives), function (nonAB) {
t.equal(byteLength(nonAB), NaN, inspect(nonAB) + ' is not an ArrayBuffer, and yields NaN');
});
t.test('ArrayBuffers', { skip: typeof ArrayBuffer !== 'function' }, function (st) {
var ab32 = new ArrayBuffer(32);
st.equal(byteLength(ab32), 32, 'works on an ArrayBuffer of length 32: ' + inspect(ab32));
var ab0 = new ArrayBuffer(0);
st.equal(byteLength(ab0), 0, 'works on an ArrayBuffer of length 0: ' + inspect(ab0));
st.end();
});
t.end();
});

36
node_modules/array.prototype.findlastindex/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,36 @@
{
"root": true,
"extends": "@ljharb",
"rules": {
"array-bracket-newline": 0,
"id-length": 0,
"new-cap": [2, {
"capIsNewExceptions": [
"GetIntrinsic",
"Call",
"Get",
"IsCallable",
"LengthOfArrayLike",
"RequireObjectCoercible",
"ToBoolean",
"ToObject",
"ToString",
],
}],
"no-magic-numbers": 0,
},
"overrides": [
{
"files": "test/**",
"rules": {
"func-name-matching": 0,
"max-lines-per-function": 0,
"no-invalid-this": 1,
"strict": 1,
},
},
],
}

View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/array.prototype.findlastindex
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

9
node_modules/array.prototype.findlastindex/.nycrc generated vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"coverage",
"test"
]
}

View File

@@ -0,0 +1,66 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.2.2](https://github.com/es-shims/Array.prototype.findLastIndex/compare/v1.2.1...v1.2.2) - 2022-11-02
### Commits
- [meta] use `npmignore` to autogenerate an npmignore file [`f910dc6`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/f910dc6e5999e6941892232810ae9b3910d925ec)
- [Deps] update `es-abstract`, `get-intrinsic` [`6e44207`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/6e4420705d7435b8b9bb978e4858814ba0216fa5)
- [actions] update rebase action to use reusable workflow [`aac0471`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/aac0471a0b2f0f44765ac6055211b58f26fa6636)
- [Deps] update `define-properties`, `es-abstract`, `get-intrinsic` [`c1d1d70`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/c1d1d7083bfa8ab32a9e5560e4b2aa16ce9d0a6d)
- [Dev Deps] update `es-value-fixtures`, `object-inspect`, `tape` [`64c4c0f`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/64c4c0f6dda4793c5d9db5110ec82c6004bcc4ef)
- [Dev Deps] update `aud`, `tape` [`603fbac`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/603fbacf4d034298ff40ab6886f6af7031651acd)
- [Tests] add indication of whether it was shimmed [`7d711f6`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/7d711f6e68c9c5e4e0556946d026c159f7d82f22)
- [Tests] make nullish receiver tests more robust [`335cf53`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/335cf5381ec0bc7ce60de8824b736cb3b40918ae)
## [v1.2.1](https://github.com/es-shims/Array.prototype.findLastIndex/compare/v1.2.0...v1.2.1) - 2022-04-11
### Commits
- [Refactor] use `es-shim-unscopables` [`abe84ee`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/abe84ee8794ce9c84180bc01cf499a7bb2494b3d)
## [v1.2.0](https://github.com/es-shims/Array.prototype.findLastIndex/compare/v1.1.1...v1.2.0) - 2022-04-11
### Commits
- [actions] reuse common workflows [`670cc4c`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/670cc4c0b6f23b7f01d365a9afd2dd88ee2e4967)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `object-inspect`, `safe-publish-latest`, `tape` [`11bc460`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/11bc460ab842d2a08c43b67aab182e0697d65308)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`b076ad6`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/b076ad6ed9246f3139efa72d0ddbf2e0d861f982)
- [actions] update codecov uploader [`0d62d86`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/0d62d8602c2d3ecefdd0965c25cafb2a864c0903)
- [New] `shim`/`auto`: add `findLast` to `Symbol.unscopables` [`b09e4a6`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/b09e4a6a194366b45945c6d65cdcc64ca786e570)
- [Deps] update `es-abstract` [`024128c`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/024128c1abc5b58863859ea8b9cf4c1cb1df548b)
- [Deps] update `es-abstract` [`2dcab99`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/2dcab99e3ed43546cd6610b12d489d95d8e94d90)
## [v1.1.1](https://github.com/es-shims/Array.prototype.findLastIndex/compare/v1.1.0...v1.1.1) - 2021-10-01
### Commits
- [Refactor] remove unnecessary ESM files [`35161c7`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/35161c76758835dd3fbecdf0b5fbf41a3ce9f218)
- [Tests] add new tests from test262 [`e26fa25`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/e26fa256601f60b1feb5918e4fbcc76d0d773d13)
- [Deps] update `es-abstract` [`5ff80b1`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/5ff80b116f2e083ae72605275af0efec367f3a89)
- [readme] fix URLs [`b962fe2`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/b962fe225fac8a450624d861b5d6e444526bcf32)
- [Dev Deps] update `@ljharb/eslint-config`, `@es-shims/api` [`5aa11dd`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/5aa11dd23ee2bcdc9ca7d2d6007e7f44a9356743)
## [v1.1.0](https://github.com/es-shims/Array.prototype.findLastIndex/compare/v1.0.0...v1.1.0) - 2021-08-07
### Commits
- [New] add ESM entry points [`ac5ada3`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/ac5ada3d359ff267e6933dd817f4106e6de2c157)
- [Fix] ES3 engines: ensure nullish receiver throws [`4c6592a`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/4c6592a7962351e82bb1b06c79de496bf4bcd08d)
- [Dev Deps] update `eslint`, `@tape` [`6895166`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/6895166742a738a80d19ac4eaa6f12c97a5c7814)
- [Fix] add missing entry points to `exports` [`ac2f138`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/ac2f1384dcd9a9f736ce1c3c5dc7ac87e16c4f90)
- [Deps] update `es-abstract` [`c379fb7`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/c379fb7681ea3bb078891bf394756b1086bc43e7)
## v1.0.0 - 2021-07-13
### Commits
- Implementation & Tests [`cf5cae1`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/cf5cae1d78c0c74588a5baade5156950e17f4558)
- Initial commit [`2778f1c`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/2778f1cc708cc79d3bdbc20d5b84d210b9670b8a)
- npm init [`873482d`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/873482d650b6800e9484865c3b0d6d33664bcf9e)
- Only apps should have lockfiles [`b7c73ee`](https://github.com/es-shims/Array.prototype.findLastIndex/commit/b7c73ee858f01b0b1ff70800e09c0bbc2632e1a5)

21
node_modules/array.prototype.findlastindex/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 ECMAScript Shims
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

74
node_modules/array.prototype.findlastindex/README.md generated vendored Normal file
View File

@@ -0,0 +1,74 @@
# array.prototype.findlastindex <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
An ESnext spec-compliant `Array.prototype.findLastIndex` shim/polyfill/replacement that works as far down as ES3.
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the proposed [spec](https://tc39.es/proposal-array-find-from-last).
Because `Array.prototype.findLastIndex` depends on a receiver (the `this` value), the main export takes the array to operate on as the first argument.
## Getting started
```sh
npm install --save array.prototype.findlastindex
```
## Usage/Examples
```js
var findLastIndex = require('array.prototype.findlastindex');
var assert = require('assert');
var arr = [1, [2], [], 3, [[4]]];
var isNumber = function (x) { return typeof x === 'number' };
assert.deepEqual(findLastIndex(arr, isNumber), 3);
```
```js
var findLastIndex = require('array.prototype.findlastindex');
var assert = require('assert');
/* when Array#findLastIndex is not present */
delete Array.prototype.findLastIndex;
var shimmed = findLastIndex.shim();
assert.equal(shimmed, findLastIndex.getPolyfill());
assert.deepEqual(arr.findLastIndex(isNumber), findLastIndex(arr, isNumber));
```
```js
var findLastIndex = require('array.prototype.findlastindex');
var assert = require('assert');
/* when Array#findLastIndex is present */
var shimmed = findLastIndex.shim();
assert.equal(shimmed, Array.prototype.findLastIndex);
assert.deepEqual(arr.findLastIndex(isNumber), findLastIndex(arr, isNumber));
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/array.prototype.findlastindex
[npm-version-svg]: https://versionbadg.es/es-shims/Array.prototype.findLastIndex.svg
[deps-svg]: https://david-dm.org/es-shims/Array.prototype.findLastIndex.svg
[deps-url]: https://david-dm.org/es-shims/Array.prototype.findLastIndex
[dev-deps-svg]: https://david-dm.org/es-shims/Array.prototype.findLastIndex/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/Array.prototype.findLastIndex#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/array.prototype.findlastindex.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/array.prototype.findlastindex.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/array.prototype.findlastindex.svg
[downloads-url]: https://npm-stat.com/charts.html?package=array.prototype.findlastindex
[codecov-image]: https://codecov.io/gh/es-shims/Array.prototype.findLastIndex/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/Array.prototype.findLastIndex/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Array.prototype.findLastIndex
[actions-url]: https://github.com/es-shims/Array.prototype.findLastIndex

3
node_modules/array.prototype.findlastindex/auto.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,39 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Call = require('es-abstract/2022/Call');
var Get = require('es-abstract/2022/Get');
var IsCallable = require('es-abstract/2022/IsCallable');
var LengthOfArrayLike = require('es-abstract/2022/LengthOfArrayLike');
var ToBoolean = require('es-abstract/2022/ToBoolean');
var ToObject = require('es-abstract/2022/ToObject');
var ToString = require('es-abstract/2022/ToString');
module.exports = function findLastIndex(predicate) {
var O = ToObject(this);
var len = LengthOfArrayLike(O);
if (!IsCallable(predicate)) {
throw new $TypeError('predicate must be a function');
}
var thisArg;
if (arguments.length > 1) {
thisArg = arguments[1];
}
var k = len - 1;
while (k >= 0) {
var Pk = ToString(k);
var kValue = Get(O, Pk);
var testResult = ToBoolean(Call(predicate, thisArg, [kValue, k, O]));
if (testResult) {
return k;
}
k -= 1;
}
return -1;
};

28
node_modules/array.prototype.findlastindex/index.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var callBound = require('call-bind/callBound');
var RequireObjectCoercible = require('es-abstract/2022/RequireObjectCoercible');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var polyfill = getPolyfill();
var shim = require('./shim');
var $slice = callBound('Array.prototype.slice');
var bound = callBind.apply(polyfill);
// eslint-disable-next-line no-unused-vars
var boundFindLast = function findLastIndex(array, predicate) {
RequireObjectCoercible(array);
return bound(array, $slice(arguments, 1));
};
define(boundFindLast, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = boundFindLast;

18
node_modules/array.prototype.findlastindex/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import callBind from 'call-bind';
import callBound from 'call-bind/callBound';
import RequireObjectCoercible from 'es-abstract/2022/RequireObjectCoercible.js';
import getPolyfill from 'array.prototype.findlastindex/polyfill';
const bound = callBind.apply(getPolyfill());
const $slice = callBound('Array.prototype.slice');
// eslint-disable-next-line no-unused-vars
export default function findLastIndex(array, predicate) {
RequireObjectCoercible(array);
return bound(array, $slice(arguments, 1));
}
export { default as getPolyfill } from 'array.prototype.findlastindex/polyfill';
export { default as implementation } from 'array.prototype.findlastindex/implementation';
export { default as shim } from 'array.prototype.findlastindex/shim';

119
node_modules/array.prototype.findlastindex/package.json generated vendored Normal file
View File

@@ -0,0 +1,119 @@
{
"name": "array.prototype.findlastindex",
"version": "1.2.2",
"description": "An ESnext spec-compliant `Array.prototype.findLastIndex` shim/polyfill/replacement that works as far down as ES3.",
"author": {
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"contributors": [
{
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/es-shims/Array.prototype.findLastIndex/issues"
},
"homepage": "https://github.com/es-shims/Array.prototype.findLastIndex#readme",
"main": "index.js",
"exports": {
".": [
{
"import": "./index.mjs",
"require": "./index.js",
"default": "./index.js"
},
"./index.js"
],
"./auto": "./auto.js",
"./polyfill": "./polyfill.js",
"./implementation": "./implementation.js",
"./shim": "./shim.js",
"./package.json": "./package.json"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"pretest": "npm run --silent lint",
"posttest": "aud --production",
"tests-only": "nyc tape 'test/**/*.js'",
"tests-esm": "nyc node test/index.mjs",
"test": "npm run tests-only && npm run tests-esm",
"prelint": "evalmd README.md",
"lint": "eslint --ext=js,mjs .",
"postlint": "es-shim-api --bound",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/es-shims/Array.prototype.findLastIndex.git"
},
"keywords": [
"Array.prototype.findLastIndex",
"find",
"findLast",
"findLastIndex",
"array",
"ESnext",
"shim",
"polyfill",
"last",
"es-shim API"
],
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.4",
"es-abstract": "^1.20.4",
"es-shim-unscopables": "^1.0.0",
"get-intrinsic": "^1.1.3"
},
"devDependencies": {
"@es-shims/api": "^2.2.3",
"@ljharb/eslint-config": "^21.0.0",
"aud": "^2.0.1",
"auto-changelog": "^2.4.0",
"es-value-fixtures": "^1.4.2",
"eslint": "=8.8.0",
"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"has": "^1.0.3",
"has-strict-mode": "^1.0.1",
"in-publish": "^2.0.1",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"object-inspect": "^1.12.2",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.1"
},
"testling": {
"files": [
"test/index.js",
"test/shimmed.js"
]
},
"engines": {
"node": ">= 0.4"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows"
]
}
}

View File

@@ -0,0 +1,7 @@
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return Array.prototype.findLastIndex || implementation;
};

18
node_modules/array.prototype.findlastindex/shim.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
var shimUnscopables = require('es-shim-unscopables');
module.exports = function shimFindLastIndex() {
var polyfill = getPolyfill();
define(
Array.prototype,
{ findLastIndex: polyfill },
{ findLastIndex: function () { return Array.prototype.findLastIndex !== polyfill; } }
);
shimUnscopables('findLastIndex');
return polyfill;
};

View File

@@ -0,0 +1,20 @@
'use strict';
var implementation = require('../implementation');
var callBind = require('call-bind');
var test = require('tape');
var hasStrictMode = require('has-strict-mode')();
var runTests = require('./tests');
test('as a function', function (t) {
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
/* eslint no-useless-call: 0 */
st['throws'](function () { implementation.call(undefined); }, TypeError, 'undefined is not an object');
st['throws'](function () { implementation.call(null); }, TypeError, 'null is not an object');
st.end();
});
runTests(callBind(implementation), t);
t.end();
});

View File

@@ -0,0 +1,18 @@
'use strict';
var index = require('../');
var callBind = require('call-bind');
var test = require('tape');
var runTests = require('./tests');
test('as a function', function (t) {
t.test('bad array/this value', function (st) {
st['throws'](callBind(index, null, undefined, function () {}), TypeError, 'undefined is not an object');
st['throws'](callBind(index, null, null, function () {}), TypeError, 'null is not an object');
st.end();
});
runTests(index, t);
t.end();
});

View File

@@ -0,0 +1,31 @@
import findLastIndex from 'array.prototype.findlastindex';
import * as Module from 'array.prototype.findlastindex';
import test from 'tape';
import runTests from './tests.js';
test('as a function', (t) => {
t.test('bad array/this value', (st) => {
st.throws(() => findLastIndex(undefined), TypeError, 'undefined is not an object');
st.throws(() => findLastIndex(null), TypeError, 'null is not an object');
st.end();
});
runTests(findLastIndex, t);
t.end();
});
test('named exports', async (t) => {
t.deepEqual(
Object.keys(Module).sort(),
['default', 'shim', 'getPolyfill', 'implementation'].sort(),
'has expected named exports',
);
const { shim, getPolyfill, implementation } = Module;
t.equal((await import('array.prototype.findlastindex/shim')).default, shim, 'shim named export matches deep export');
t.equal((await import('array.prototype.findlastindex/implementation')).default, implementation, 'implementation named export matches deep export');
t.equal((await import('array.prototype.findlastindex/polyfill')).default, getPolyfill, 'getPolyfill named export matches deep export');
t.end();
});

View File

@@ -0,0 +1,47 @@
'use strict';
var orig = Array.prototype.findLastIndex;
require('../auto');
var test = require('tape');
var has = require('has');
var defineProperties = require('define-properties');
var callBind = require('call-bind');
var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = function f() {}.name === 'f';
var runTests = require('./tests');
test('shimmed', function (t) {
t.comment('shimmed: ' + (orig === Array.prototype.findLastIndex ? 'no' : 'yes'));
t.equal(Array.prototype.findLastIndex.length, 1, 'Array#findLastIndex has a length of 1');
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
st.equal(Array.prototype.findLastIndex.name, 'findLastIndex', 'Array#findLastIndex has name "findLastIndex"');
st.end();
});
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(Array.prototype, 'findLastIndex'), 'Array#findLastIndex is not enumerable');
et.end();
});
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) {
st['throws'](function () { return Array.prototype.findLastIndex.call(undefined, function () {}); }, TypeError, 'undefined is not an object');
st['throws'](function () { return Array.prototype.findLastIndex.call(null, function () {}); }, TypeError, 'null is not an object');
st.end();
});
t.test('Symbol.unscopables', { skip: typeof Symbol !== 'function' || typeof Symbol.unscopables !== 'symbol' }, function (st) {
st.ok(has(Array.prototype[Symbol.unscopables], 'findLastIndex'), 'Array.prototype[Symbol.unscopables] has own `findLastIndex` property');
st.equal(Array.prototype[Symbol.unscopables].findLastIndex, true, 'Array.prototype[Symbol.unscopables].findLastIndex is true');
st.end();
});
runTests(callBind(Array.prototype.findLastIndex), t);
t.end();
});

View File

@@ -0,0 +1,230 @@
var hasStrictMode = require('has-strict-mode')();
var v = require('es-value-fixtures');
var forEach = require('for-each');
var inspect = require('object-inspect');
var global = Function('return this')(); // eslint-disable-line no-new-func
var trueThunk = function () { return true; };
var falseThunk = function () { return false; };
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false.
var undefinedIfNoSparseBug = canDistinguishSparseFromUndefined ? undefined : { valueOf: function () { return 0; } };
var createArrayLikeFromArray = function createArrayLikeFromArray(arr) {
var o = {};
for (var i = 0; i < arr.length; i += 1) {
if (i in arr) {
o[i] = arr[i];
}
}
o.length = arr.length;
return o;
};
var getTestArr = function () {
var arr = [0, false, null, 'hej', true, undefinedIfNoSparseBug, 3, 2];
delete arr[6];
return arr;
};
module.exports = function (findLastIndex, t) {
forEach(v.nonArrays, function (nonArray) {
if (nonArray != null) { // eslint-disable-line eqeqeq
t.equal(
findLastIndex(nonArray, function () { return true; }),
typeof nonArray.length === 'number' ? nonArray.length - 1 : -1,
inspect(nonArray) + ' is not an array'
);
}
});
t.test('throws on a non-callable predicate', function (st) {
forEach(v.nonFunctions, function (nonFunction) {
st['throws'](
function () { findLastIndex([], nonFunction); },
TypeError,
inspect(nonFunction) + ' is not a Function'
);
});
st.end();
});
t.test('passes the correct values to the callback', function (st) {
st.plan(5);
var expectedValue = {};
var arr = [expectedValue];
var context = {};
findLastIndex(arr, function (value, key, list) {
st.equal(arguments.length, 3);
st.equal(value, expectedValue, 'first argument is the value');
st.equal(key, 0, 'second argument is the index');
st.equal(list, arr, 'third argument is the array being iterated');
st.equal(this, context, 'receiver is the expected value');
return true;
}, context);
st.end();
});
t.test('does not visit elements added to the array after it has begun', function (st) {
st.plan(2);
var arr = [1, 2, 3];
var i = 0;
findLastIndex(arr, function (a) {
i += 1;
arr.push(a + 3);
return i > 3;
});
st.deepEqual(arr, [1, 2, 3, 6, 5, 4], 'array has received 3 new elements');
st.equal(i, 3, 'findLastIndex callback only called thrice');
st.end();
});
t.test('does not visit elements deleted from the array after it has begun', function (st) {
var arr = [1, 2, 3];
var actual = [];
findLastIndex(arr, function (x, i) {
actual.push([i, x]);
delete arr[1];
return false;
});
st.deepEqual(actual, [[2, 3], [1, undefined], [0, 1]]);
st.end();
});
t.test('sets the right context when given none', function (st) {
var context;
findLastIndex([1], function () { context = this; });
st.equal(context, global, 'receiver is global object in sloppy mode');
st.test('strict mode', { skip: !hasStrictMode }, function (sst) {
findLastIndex([1], function () {
'use strict';
context = this;
});
sst.equal(context, undefined, 'receiver is undefined in strict mode');
sst.end();
});
st.end();
});
t.test('empty array', function (st) {
st.equal(findLastIndex([], trueThunk), -1, 'true thunk callback yields -1');
st.equal(findLastIndex([], falseThunk), -1, 'false thunk callback yields -1');
var counter = 0;
var callback = function () { counter += 1; };
findLastIndex([], callback);
st.equal(counter, 0, 'counter is not incremented');
st.end();
});
t.equal(findLastIndex([1, 2, 3], trueThunk), 2, 'returns last index if findLastIndex callback returns true');
t.equal(findLastIndex([1, 2, 3], falseThunk), -1, 'returns -1 if no callback returns true');
t.test('stopping after N elements', function (st) {
st.test('no context', function (sst) {
var actual = {};
var count = 0;
findLastIndex(getTestArr(), function (obj, index) {
actual[index] = obj;
count += 1;
return count === 4;
});
sst.deepEqual(actual, { 4: true, 5: undefinedIfNoSparseBug, 6: undefined, 7: 2 });
sst.end();
});
st.test('with context', function (sst) {
var actual = {};
var context = { actual: actual };
var count = 0;
findLastIndex(getTestArr(), function (obj, index) {
this.actual[index] = obj;
count += 1;
return count === 4;
}, context);
sst.deepEqual(actual, { 4: true, 5: undefinedIfNoSparseBug, 6: undefined, 7: 2 });
sst.end();
});
st.test('arraylike, no context', function (sst) {
var actual = {};
var count = 0;
findLastIndex(createArrayLikeFromArray(getTestArr()), function (obj, index) {
actual[index] = obj;
count += 1;
return count === 4;
});
sst.deepEqual(actual, { 4: true, 5: undefinedIfNoSparseBug, 6: undefined, 7: 2 });
sst.end();
});
st.test('arraylike, context', function (sst) {
var actual = {};
var count = 0;
var context = { actual: actual };
findLastIndex(createArrayLikeFromArray(getTestArr()), function (obj, index) {
this.actual[index] = obj;
count += 1;
return count === 4;
}, context);
sst.deepEqual(actual, { 4: true, 5: undefinedIfNoSparseBug, 6: undefined, 7: 2 });
sst.end();
});
st.end();
});
t.test('list arg boxing', function (st) {
st.plan(3);
findLastIndex('bar', function (item, index, list) {
st.equal(item, 'r', 'last letter matches');
st.equal(typeof list, 'object', 'primitive list arg is boxed');
st.equal(Object.prototype.toString.call(list), '[object String]', 'boxed list arg is a String');
return true;
});
st.end();
});
t.test('array altered during loop', function (st) {
var arr = ['Shoes', 'Car', 'Bike'];
var results = [];
findLastIndex(arr, function (kValue) {
if (results.length === 0) {
arr.splice(1, 1);
}
results.push(kValue);
});
st.equal(results.length, 3, 'predicate called three times');
st.deepEqual(results, ['Bike', 'Bike', 'Shoes']);
results = [];
arr = ['Skateboard', 'Barefoot'];
findLastIndex(arr, function (kValue) {
if (results.length === 0) {
arr.push('Motorcycle');
arr[0] = 'Magic Carpet';
}
results.push(kValue);
});
st.equal(results.length, 2, 'predicate called twice');
st.deepEqual(results, ['Barefoot', 'Magic Carpet']);
st.end();
});
};

13
node_modules/arraybuffer.prototype.slice/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,13 @@
root = true
[*]
indent_style = tab;
insert_final_newline = true;
quote_type = auto;
space_after_anonymous_functions = true;
space_after_control_statements = true;
spaces_around_operators = true;
trim_trailing_whitespace = true;
spaces_in_brackets = false;
end_of_line = lf;

34
node_modules/arraybuffer.prototype.slice/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,34 @@
{
"root": true,
"extends": "@ljharb",
"rules": {
"id-length": 0,
"max-params": 0,
"max-statements": 0,
"multiline-comment-style": 0,
"new-cap": [2, {
"capIsNewExceptions": [
"IsSharedArrayBuffer",
"ToIntegerOrInfinity",
"GetIntrinsic",
"IsDetachedBuffer",
"SpeciesConstructor",
],
}],
},
"overrides": [
{
"files": "test/**",
"globals": {
"ArrayBuffer": false,
"Uint8Array": false,
},
"rules": {
"max-lines-per-function": 0,
},
},
],
}

9
node_modules/arraybuffer.prototype.slice/.nycrc generated vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"coverage",
"test"
]
}

23
node_modules/arraybuffer.prototype.slice/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.0.1](https://github.com/es-shims/ArrayBuffer.prototype.slice/compare/v1.0.0...v1.0.1) - 2023-07-11
### Commits
- [Fix] node &lt; 0.11 has an own nonconfigurable `slice` property; use it [`554823c`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/554823c92ce16d6b7184a7d0ccfe315b663584d7)
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud`, `es-abstract`, `tape` [`53b0421`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/53b04217048c645306597e2cfc55adb69c384146)
- [Deps] update `define-properties`, `get-intrinsic` [`4966b02`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/4966b02bc25ac006709b29ca370b9f6e159f723a)
## v1.0.0 - 2023-07-09
### Commits
- Initial implementation, tests, readme [`36b4b5e`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/36b4b5eedfa225c3086e9453b9db0088c299640a)
- Initial commit [`51499df`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/51499dfac7d8c67c2928cb47363a4de7ff17904a)
- npm init [`8ec604e`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/8ec604e7d3ef8d4c27376b09645f779c2244b08f)
- Only apps should have lockfiles [`ac54435`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/ac54435161d4415e2122e3a682499f3a6df2f6de)

21
node_modules/arraybuffer.prototype.slice/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 ECMAScript Shims
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

61
node_modules/arraybuffer.prototype.slice/README.md generated vendored Normal file
View File

@@ -0,0 +1,61 @@
# ArrayBuffer.prototype.slice <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
An ES spec-compliant `ArrayBuffer.prototype.slice` shim. Invoke its "shim" method to shim ArrayBuffer.prototype.slice if it is unavailable.
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES5-supported environment and complies with the [spec](https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice).
Most common usage:
```js
var assert = require('assert');
var slice = require('arraybuffer.prototype.slice');
var ab = new ArrayBuffer(1);
var arr = new Uint8Array(ab);
arr[0] = 123;
var ab2 = slice(ab);
var arr2 = new Uint8Array(ab2);
arr2[0] = 234;
assert.deepEqual(arr, new Uint8Array([123]));
assert.deepEqual(arr2, new Uint8Array([234]));
if (!ArrayBuffer.prototype.transfer) {
slice.shim();
}
var ab2 = ab.slice();
var arr2 = new Uint8Array(ab2);
arr2[0] = 234;
assert.deepEqual(arr, new Uint8Array([123]));
assert.deepEqual(arr2, new Uint8Array([234]));
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/arraybuffer.prototype.slice
[npm-version-svg]: https://versionbadg.es/es-shims/ArrayBuffer.prototype.slice.svg
[deps-svg]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice.svg
[deps-url]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice
[dev-deps-svg]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/arraybuffer.prototype.slice.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/arraybuffer.prototype.slice.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/arraybuffer.prototype.slice.svg
[downloads-url]: https://npm-stat.com/charts.html?package=arraybuffer.prototype.slice
[codecov-image]: https://codecov.io/gh/es-shims/ArrayBuffer.prototype.slice/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/ArrayBuffer.prototype.slice/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/ArrayBuffer.prototype.slice
[actions-url]: https://github.com/es-shims/ArrayBuffer.prototype.slice/actions

3
node_modules/arraybuffer.prototype.slice/auto.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
require('./shim')();

View File

@@ -0,0 +1,84 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $ArrayBuffer = GetIntrinsic('%ArrayBuffer%', true);
var $TypeError = GetIntrinsic('%TypeError%');
var $Uint8Array = GetIntrinsic('%Uint8Array%', true);
var IsDetachedBuffer = require('es-abstract/2022/IsDetachedBuffer');
var IsSharedArrayBuffer = require('es-abstract/2022/IsSharedArrayBuffer');
var max = require('es-abstract/2022/max');
var min = require('es-abstract/2022/min');
var SpeciesConstructor = require('es-abstract/2022/SpeciesConstructor');
var ToIntegerOrInfinity = require('es-abstract/2022/ToIntegerOrInfinity');
var arrayBufferByteLength = require('array-buffer-byte-length');
var isArrayBuffer = require('is-array-buffer');
module.exports = function slice(start, end) {
var O = this; // step 1
if (!isArrayBuffer(O) || IsSharedArrayBuffer(O) || IsDetachedBuffer(O)) {
throw new $TypeError('receiver must be a non-detached, non-shared ArrayBuffer'); // steps 2-4
}
var len = arrayBufferByteLength(O); // step 5
var relativeStart = ToIntegerOrInfinity(start); // step 6
var first;
if (relativeStart === -Infinity) {
first = 0; // step 7
} else if (relativeStart < 0) {
first = max(len + relativeStart, 0); // step 8
} else {
first = min(relativeStart, len); // step 9
}
var relativeEnd = typeof end === 'undefined' ? len : ToIntegerOrInfinity(end); // step 10
var final;
if (relativeEnd === -Infinity) {
final = 0; // step 11
} else if (relativeEnd < 0) {
final = max(len + relativeEnd, 0); // step 12
} else {
final = min(relativeEnd, len); // step 13
}
var newLen = max(final - first, 0); // step 14
var Ctor = SpeciesConstructor(O, $ArrayBuffer); // step 15
var new$ = new Ctor(newLen); // step 16
if (!isArrayBuffer(new$) || IsSharedArrayBuffer(new$) || IsDetachedBuffer(new$)) {
throw new $TypeError('Species constructor must produce a non-detached, non-shared Array Buffer'); // steps 17-19
}
if (new$ === O) {
throw new $TypeError('new ArrayBuffer should not have been the same as the receiver'); // step 20
}
if (arrayBufferByteLength(new$) < newLen) {
throw new $TypeError('new ArrayBuffer\'s byteLength must be at least the requested length'); // step 21
}
if (IsDetachedBuffer(O)) {
throw new $TypeError('receiver became an detached ArrayBuffer'); // step 23
}
/*
24. Let fromBuf be O.[[ArrayBufferData]].
25. Let toBuf be new.[[ArrayBufferData]].
26. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, newLen).
*/
var sourceArr = new $Uint8Array(O);
var destArr = new $Uint8Array(new$);
for (var i = start, ii = 0; i < end; i++, ii++) {
destArr[ii] = sourceArr[i];
}
return new$; // step 27
};

18
node_modules/arraybuffer.prototype.slice/index.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var bound = callBind(getPolyfill());
define(bound, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = bound;

103
node_modules/arraybuffer.prototype.slice/package.json generated vendored Normal file
View File

@@ -0,0 +1,103 @@
{
"name": "arraybuffer.prototype.slice",
"version": "1.0.1",
"description": "ES spec-compliant shim for ArrayBuffer.prototype.slice",
"author": "Jordan Harband <ljharb@gmail.com>",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"main": "index.js",
"exports": {
".": "./index.js",
"./auto": "./auto.js",
"./polyfill": "./polyfill.js",
"./implementation": "./implementation.js",
"./shim": "./shim.js",
"./package.json": "./package.json"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"pretest": "npm run lint",
"test": "npm run tests-only",
"posttest": "aud --production",
"tests-only": "nyc tape 'test/**/*.js'",
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
"lint": "eslint --ext=js,mjs .",
"postlint": "evalmd README.md && es-shim-api --bound",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/es-shims/ArrayBuffer.prototype.slice.git"
},
"homepage": "https://github.com/es-shims/ArrayBuffer.prototype.slice#readme",
"bugs": {
"url": "https://github.com/es-shims/ArrayBuffer.prototype.slice/issues"
},
"keywords": [
"javascript",
"ecmascript",
"ArrayBuffer.prototype.slice",
"polyfill",
"shim",
"ArrayBuffer",
"array",
"buffer",
"ArrayBuffer#slice",
"slice",
"typed array",
"es-shim API"
],
"dependencies": {
"array-buffer-byte-length": "^1.0.0",
"call-bind": "^1.0.2",
"define-properties": "^1.2.0",
"get-intrinsic": "^1.2.1",
"is-array-buffer": "^3.0.2",
"is-shared-array-buffer": "^1.0.2"
},
"devDependencies": {
"@es-shims/api": "^2.4.2",
"@ljharb/eslint-config": "^21.1.0",
"aud": "^2.0.3",
"auto-changelog": "^2.4.0",
"covert": "^1.1.1",
"eclint": "^2.8.1",
"es-abstract": "^1.21.2",
"es-value-fixtures": "^1.4.2",
"eslint": "=8.8.0",
"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"functions-have-names": "^1.2.3",
"has-strict-mode": "^1.0.1",
"in-publish": "^2.0.1",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"object-inspect": "^1.12.3",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.4"
},
"testling": {
"files": "test/index.js"
},
"engines": {
"node": ">= 0.4"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows"
]
}
}

21
node_modules/arraybuffer.prototype.slice/polyfill.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
var callBind = require('call-bind');
var implementation = require('./implementation');
var ownSlice = typeof ArrayBuffer === 'function' && new ArrayBuffer(0).slice;
var ownSliceBound = ownSlice && callBind(ownSlice);
var ownSliceWrapper = ownSliceBound && function slice(start, end) {
/* eslint no-invalid-this: 0 */
if (arguments.length < 2) {
return ownSliceBound(this, arguments.length > 0 ? start : 0);
}
return ownSliceBound(this, start, end);
};
module.exports = function getPolyfill() {
return (typeof ArrayBuffer === 'function' && ArrayBuffer.prototype.slice)
|| ownSliceWrapper
|| implementation;
};

18
node_modules/arraybuffer.prototype.slice/shim.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
module.exports = function shimArrayBufferSlice() {
if (typeof ArrayBuffer === 'function') {
var polyfill = getPolyfill();
define(
ArrayBuffer.prototype,
{ slice: polyfill },
{ slice: function () { return ArrayBuffer.prototype.slice !== polyfill; } }
);
}
return polyfill;
};

View File

@@ -0,0 +1,32 @@
'use strict';
var implementation = require('../implementation');
var callBind = require('call-bind');
var test = require('tape');
var hasStrictMode = require('has-strict-mode')();
var runTests = require('./tests');
test('as a function', function (t) {
t.test('ArrayBuffer support', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
st.test('bad array/this value', { skip: !hasStrictMode }, function (s2t) {
/* eslint no-useless-call: 0 */
s2t['throws'](function () { implementation.call(undefined); }, TypeError, 'undefined is not an object');
s2t['throws'](function () { implementation.call(null); }, TypeError, 'null is not an object');
s2t.end();
});
runTests(callBind(implementation), st);
st.end();
});
t.test('no ArrayBuffer support', { skip: typeof ArrayBuffer !== 'undefined' }, function (st) {
st['throws'](
function () { implementation.call({}); },
SyntaxError,
'ArrayBuffer is not supported'
);
});
t.end();
});

29
node_modules/arraybuffer.prototype.slice/test/index.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
'use strict';
var index = require('../');
var test = require('tape');
var runTests = require('./tests');
test('as a function', function (t) {
t.test('ArrayBuffer support', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
st.test('bad array/this value', function (s2t) {
s2t['throws'](function () { index(undefined); }, TypeError, 'undefined is not an object');
s2t['throws'](function () { index(null); }, TypeError, 'null is not an object');
s2t.end();
});
runTests(index, st);
st.end();
});
t.test('no ArrayBuffer support', { skip: typeof ArrayBuffer !== 'undefined' }, function (st) {
st['throws'](
function () { index({}); },
SyntaxError,
'ArrayBuffer is not supported'
);
});
t.end();
});

View File

@@ -0,0 +1,54 @@
'use strict';
require('../auto');
var test = require('tape');
var defineProperties = require('define-properties');
var callBind = require('call-bind');
var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = require('functions-have-names')();
var hasStrictMode = require('has-strict-mode')();
var runTests = require('./tests');
test('shimmed', function (t) {
t.test('ArrayBuffer support', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
var method = ArrayBuffer.prototype.slice;
st.equal(method.length, 2, 'ArrayBuffer#slice has a length of 2');
st.test('Function name', { skip: !functionsHaveNames }, function (s2t) {
s2t.equal(method.name, 'slice', 'ArrayBuffer#slice name "slice"');
s2t.end();
});
st.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(ArrayBuffer.prototype, 'slice'), 'ArrayBuffer#slice is not enumerable');
et.end();
});
st.test('bad array/this value', { skip: !hasStrictMode }, function (s2t) {
/* eslint no-useless-call: 0 */
s2t['throws'](function () { return method.call(undefined); }, TypeError, 'undefined is not an object');
s2t['throws'](function () { return method.call(null); }, TypeError, 'null is not an object');
s2t.end();
});
t.test('has the correct descriptor', { skip: !Object.getOwnPropertyDescriptor }, function (s2t) {
var descriptor = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'slice');
s2t.equal(descriptor.configurable, true);
s2t.equal(descriptor.enumerable, false);
s2t.equal(typeof descriptor.value, 'function');
s2t.equal(descriptor.writable, true);
s2t.end();
});
runTests(callBind(method), st);
st.end();
});
t.end();
});

81
node_modules/arraybuffer.prototype.slice/test/tests.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
'use strict';
var inspect = require('object-inspect');
var IsDetachedBuffer = require('es-abstract/2022/IsDetachedBuffer');
var forEach = require('for-each');
var v = require('es-value-fixtures');
var byteLength = require('array-buffer-byte-length');
module.exports = function runTests(slice, t) {
forEach(v.primitives.concat(v.objects), function (nonAB) {
t['throws'](
function () { slice(nonAB); },
TypeError,
inspect(nonAB) + ' is not an ArrayBuffer'
);
});
t.test('ArrayBuffers', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
var ab = new ArrayBuffer(0);
st.equal(IsDetachedBuffer(ab), false, 'ArrayBuffer is not detached');
try {
var nb = slice(ab);
} catch (e) {
if (e instanceof SyntaxError) {
st.skip('Detaching ArrayBuffer is not supported');
return st.end();
}
console.log(e.stack);
}
st.notEqual(nb, ab, 'new ArrayBuffer is not the same as the original');
st.equal(IsDetachedBuffer(ab), false, 'old ArrayBuffer is not detached');
st.equal(IsDetachedBuffer(nb), false, 'new ArrayBuffer is not detached');
var ab2 = new ArrayBuffer(8);
st.equal(byteLength(ab2), 8, 'original ArrayBuffer has length 8');
try {
var nbLen = slice(ab2, 4);
} catch (e) {
if (e instanceof SyntaxError) {
st.skip('Detaching ArrayBuffer is not supported');
return st.end();
}
}
st.equal(IsDetachedBuffer(ab2), false, 'old ArrayBuffer is not detached');
st.equal(IsDetachedBuffer(nbLen), false, 'new ArrayBuffer is not detached');
st.equal(byteLength(ab2), 8, 'original ArrayBuffer has length 8');
st.equal(byteLength(nbLen), 4, 'newly sliced ArrayBuffer has length 4');
var one = new ArrayBuffer(1);
var arr = new Uint8Array(one);
arr[0] = 123;
var two = slice(one);
var arr2 = new Uint8Array(two);
arr2[0] = 234;
st.deepEqual(arr, new Uint8Array([123]), 'original buffer is unchanged');
st.deepEqual(arr2, new Uint8Array([234]), 'sliced buffer is changed');
return st.end();
});
t.test('SharedArrayBuffers', { skip: typeof SharedArrayBuffer === 'undefined' }, function (st) {
var sab = new SharedArrayBuffer(0);
st['throws'](
function () { slice(sab); },
TypeError,
inspect(sab) + ' is not an ArrayBuffer'
);
st.end();
});
};

View File

@@ -1,3 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.2.0](https://github.com/ljharb/define-properties/compare/v1.1.4...v1.2.0) - 2023-02-10
### Commits
- [New] if the predicate is boolean `true`, it compares the existing value with `===` as the predicate [`d8dd6fc`](https://github.com/ljharb/define-properties/commit/d8dd6fca40d7c5878a4b643b91e66ae5a513a194)
- [meta] add `auto-changelog` [`7ebe2b0`](https://github.com/ljharb/define-properties/commit/7ebe2b0a0f90e62b842942cd45e86864fe75d9f6)
- [meta] use `npmignore` to autogenerate an npmignore file [`647478a`](https://github.com/ljharb/define-properties/commit/647478a8401fbf053fb633c0a3a7c982da6bad74)
- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`e620d70`](https://github.com/ljharb/define-properties/commit/e620d707d2e1118a38796f22a862200eb0a53fff)
- [Dev Deps] update `aud`, `tape` [`f1e5072`](https://github.com/ljharb/define-properties/commit/f1e507225c2551a99ed4fe40d3fe71b0f44acf88)
- [actions] update checkout action [`628b3af`](https://github.com/ljharb/define-properties/commit/628b3af5c74b8f0963296d811a8f6fa657baf964)
<!-- auto-changelog-above -->
1.1.4 / 2022-04-14
=================
* [Refactor] use `has-property-descriptors`

View File

@@ -16,8 +16,14 @@ var hasPropertyDescriptors = require('has-property-descriptors')();
var supportsDescriptors = origDefineProperty && hasPropertyDescriptors;
var defineProperty = function (object, name, value, predicate) {
if (name in object && (!isFunction(predicate) || !predicate())) {
return;
if (name in object) {
if (predicate === true) {
if (object[name] === value) {
return;
}
} else if (!isFunction(predicate) || !predicate()) {
return;
}
}
if (supportsDescriptors) {
origDefineProperty(object, name, {

View File

@@ -1,6 +1,6 @@
{
"name": "define-properties",
"version": "1.1.4",
"version": "1.2.0",
"author": "Jordan Harband <ljharb@gmail.com>",
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -9,13 +9,16 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"pretest": "npm run lint",
"test": "npm run tests-only",
"posttest": "aud --production",
"tests-only": "nyc tape 'test/**/*.js'",
"lint": "eslint --ext=js,mjs ."
"lint": "eslint --ext=js,mjs .",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"repository": {
"type": "git",
@@ -35,12 +38,15 @@
"object-keys": "^1.1.1"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.0.0",
"aud": "^2.0.0",
"@ljharb/eslint-config": "^21.0.1",
"aud": "^2.0.2",
"auto-changelog": "^2.4.0",
"eslint": "=8.8.0",
"in-publish": "^2.0.1",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
"tape": "^5.5.3"
"tape": "^5.6.3"
},
"testling": {
"files": "test/index.js",
@@ -62,5 +68,20 @@
},
"engines": {
"node": ">= 0.4"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true,
"startingVersion": "1.1.5"
},
"publishConfig": {
"ignore": [
".github/workflows",
"test/"
]
}
}

12
node_modules/es-abstract/.eslintrc generated vendored
View File

@@ -13,7 +13,7 @@
"eqeqeq": [2, "allow-null"],
"func-name-matching": 0,
"id-length": [2, { "min": 1, "max": 40 }],
"max-params": [2, 4],
"max-params": [2, 5],
"max-lines-per-function": 1,
"max-statements": 1,
"max-statements-per-line": [2, { "max": 2 }],
@@ -67,8 +67,16 @@
},
},
{
"files": "*/RawBytesToNum*.js",
"files": [
"*/Num*ToRawBytes.js",
"*/RawBytesToNum*.js",
"helpers/bytesAs*.js",
"helpers/valueToFloat*.js",
],
"rules": {
"max-lines-per-function": "off",
"max-statements": "off",
"no-redeclare": "warn",
"operator-linebreak": [2, "before", {
"overrides": {
"=": "none"

View File

@@ -4,7 +4,7 @@ var ToNumber = require('./ToNumber');
var ToPrimitive = require('./ToPrimitive');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-abstract-equality-comparison
// https://262.ecma-international.org/6.0/#sec-abstract-equality-comparison
module.exports = function AbstractEqualityComparison(x, y) {
var xType = Type(x);

View File

@@ -2,24 +2,24 @@
var GetIntrinsic = require('get-intrinsic');
var IsInteger = require('./IsInteger');
var Type = require('./Type');
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');
var isInteger = require('../helpers/isInteger');
var isLeadingSurrogate = require('../helpers/isLeadingSurrogate');
var isTrailingSurrogate = require('../helpers/isTrailingSurrogate');
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');
var $TypeError = GetIntrinsic('%TypeError%');
var $charCodeAt = require('call-bind/callBound')('String.prototype.charCodeAt');
// https://ecma-international.org/ecma-262/6.0/#sec-advancestringindex
// https://262.ecma-international.org/6.0/#sec-advancestringindex
module.exports = function AdvanceStringIndex(S, index, unicode) {
if (Type(S) !== 'String') {
throw new $TypeError('Assertion failed: `S` must be a String');
}
if (!IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) {
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) {
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53');
}
if (Type(unicode) !== 'Boolean') {

View File

@@ -7,7 +7,7 @@ var $RangeError = GetIntrinsic('%RangeError%');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');
var IsInteger = require('./IsInteger');
var isInteger = require('../helpers/isInteger');
var hasProto = require('has-proto')();
@@ -22,10 +22,10 @@ var $setProto = GetIntrinsic('%Object.setPrototypeOf%', true) || (
: null
);
// https://ecma-international.org/ecma-262/6.0/#sec-arraycreate
// https://262.ecma-international.org/6.0/#sec-arraycreate
module.exports = function ArrayCreate(length) {
if (!IsInteger(length) || length < 0) {
if (!isInteger(length) || length < 0) {
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0');
}
if (length > MAX_ARRAY_LENGTH) {

View File

@@ -19,7 +19,7 @@ var ToString = require('./ToString');
var ToUint32 = require('./ToUint32');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-arraysetlength
// https://262.ecma-international.org/6.0/#sec-arraysetlength
// eslint-disable-next-line max-statements, max-lines-per-function
module.exports = function ArraySetLength(A, Desc) {

View File

@@ -9,13 +9,14 @@ var $TypeError = GetIntrinsic('%TypeError%');
var Get = require('./Get');
var IsArray = require('./IsArray');
var IsConstructor = require('./IsConstructor');
var IsInteger = require('./IsInteger');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate
var isInteger = require('../helpers/isInteger');
// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate
module.exports = function ArraySpeciesCreate(originalArray, length) {
if (!IsInteger(length) || length < 0) {
if (!isInteger(length) || length < 0) {
throw new $TypeError('Assertion failed: length must be an integer >= 0');
}
var len = length === 0 ? 0 : length;

View File

@@ -7,9 +7,9 @@ var $TypeError = GetIntrinsic('%TypeError%');
var IsArray = require('./IsArray');
var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('%Function.prototype.apply%');
var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply');
// https://ecma-international.org/ecma-262/6.0/#sec-call
// https://262.ecma-international.org/6.0/#sec-call
module.exports = function Call(F, V) {
var argumentsList = arguments.length > 2 ? arguments[2] : [];

View File

@@ -9,7 +9,7 @@ var ToNumber = require('./ToNumber');
var ToString = require('./ToString');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring
// https://262.ecma-international.org/6.0/#sec-canonicalnumericindexstring
module.exports = function CanonicalNumericIndexString(argument) {
if (Type(argument) !== 'String') {

55
node_modules/es-abstract/2015/Canonicalize.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var callBound = require('call-bind/callBound');
var has = require('has');
var $charCodeAt = callBound('String.prototype.charCodeAt');
var $toUpperCase = callBound('String.prototype.toUpperCase');
var Type = require('./Type');
var caseFolding = require('../helpers/caseFolding');
// https://262.ecma-international.org/6.0/#sec-runtime-semantics-canonicalize-ch
module.exports = function Canonicalize(ch, IgnoreCase, Unicode) {
if (Type(ch) !== 'String') {
throw new $TypeError('Assertion failed: `ch` must be a character');
}
if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') {
throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be Booleans');
}
if (!IgnoreCase) {
return ch; // step 1
}
if (Unicode) { // step 2
if (has(caseFolding.C, ch)) {
return caseFolding.C[ch];
}
if (has(caseFolding.S, ch)) {
return caseFolding.S[ch];
}
return ch; // step 2.b
}
var u = $toUpperCase(ch); // step 2
if (u.length !== 1) {
return ch; // step 3
}
var cu = u; // step 4
if ($charCodeAt(ch, 0) >= 128 && $charCodeAt(cu, 0) < 128) {
return ch; // step 5
}
return cu;
};

View File

@@ -5,8 +5,8 @@ var callBound = require('call-bind/callBound');
var $fromCharCode = GetIntrinsic('%String.fromCharCode%');
var $TypeError = GetIntrinsic('%TypeError%');
var $charCodeAt = callBound('%String.prototype.charCodeAt%');
var $push = callBound('%Array.prototype.push%');
var $charCodeAt = callBound('String.prototype.charCodeAt');
var $push = callBound('Array.prototype.push');
module.exports = function CharacterRange(A, B) {
if (A.length !== 1 || B.length !== 1) {

View File

@@ -8,7 +8,7 @@ var IsDataDescriptor = require('./IsDataDescriptor');
var IsGenericDescriptor = require('./IsGenericDescriptor');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor
// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor
module.exports = function CompletePropertyDescriptor(Desc) {
/* eslint no-param-reassign: 0 */

View File

@@ -4,17 +4,11 @@ var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var DefineOwnProperty = require('../helpers/DefineOwnProperty');
var FromPropertyDescriptor = require('./FromPropertyDescriptor');
var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty');
var IsDataDescriptor = require('./IsDataDescriptor');
var IsExtensible = require('./IsExtensible');
var IsPropertyKey = require('./IsPropertyKey');
var SameValue = require('./SameValue');
var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-createdataproperty
// https://262.ecma-international.org/6.0/#sec-createdataproperty
module.exports = function CreateDataProperty(O, P, V) {
if (Type(O) !== 'Object') {
@@ -23,23 +17,11 @@ module.exports = function CreateDataProperty(O, P, V) {
if (!IsPropertyKey(P)) {
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
}
var oldDesc = OrdinaryGetOwnProperty(O, P);
var extensible = !oldDesc || IsExtensible(O);
var nonConfigurable = oldDesc && !oldDesc['[[Configurable]]'];
if (nonConfigurable || !extensible) {
return false;
}
return DefineOwnProperty(
IsDataDescriptor,
SameValue,
FromPropertyDescriptor,
O,
P,
{
'[[Configurable]]': true,
'[[Enumerable]]': true,
'[[Value]]': V,
'[[Writable]]': true
}
);
var newDesc = {
'[[Configurable]]': true,
'[[Enumerable]]': true,
'[[Value]]': V,
'[[Writable]]': true
};
return OrdinaryDefineOwnProperty(O, P, newDesc);
};

View File

@@ -8,7 +8,7 @@ var CreateDataProperty = require('./CreateDataProperty');
var IsPropertyKey = require('./IsPropertyKey');
var Type = require('./Type');
// // https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow
// // https://262.ecma-international.org/6.0/#sec-createdatapropertyorthrow
module.exports = function CreateDataPropertyOrThrow(O, P, V) {
if (Type(O) !== 'Object') {

View File

@@ -12,7 +12,7 @@ var RequireObjectCoercible = require('./RequireObjectCoercible');
var ToString = require('./ToString');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-createhtml
// https://262.ecma-international.org/6.0/#sec-createhtml
module.exports = function CreateHTML(string, tag, attribute, value) {
if (Type(tag) !== 'String' || Type(attribute) !== 'String') {

View File

@@ -6,7 +6,7 @@ var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject
// https://262.ecma-international.org/6.0/#sec-createiterresultobject
module.exports = function CreateIterResultObject(value, done) {
if (Type(done) !== 'Boolean') {

View File

@@ -14,11 +14,13 @@ var ToLength = require('./ToLength');
var ToString = require('./ToString');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-createlistfromarraylike
var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'Object'];
// https://262.ecma-international.org/6.0/#sec-createlistfromarraylike
module.exports = function CreateListFromArrayLike(obj) {
var elementTypes = arguments.length > 1
? arguments[1]
: ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'Object'];
: defaultElementTypes;
if (Type(obj) !== 'Object') {
throw new $TypeError('Assertion failed: `obj` must be an Object');

View File

@@ -12,7 +12,7 @@ var IsPropertyKey = require('./IsPropertyKey');
var SameValue = require('./SameValue');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-createmethodproperty
// https://262.ecma-international.org/6.0/#sec-createmethodproperty
module.exports = function CreateMethodProperty(O, P, V) {
if (Type(O) !== 'Object') {

View File

@@ -15,7 +15,7 @@ var SameValue = require('./SameValue');
var ToPropertyDescriptor = require('./ToPropertyDescriptor');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-definepropertyorthrow
// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow
module.exports = function DefinePropertyOrThrow(O, P, desc) {
if (Type(O) !== 'Object') {

View File

@@ -7,7 +7,7 @@ var $TypeError = GetIntrinsic('%TypeError%');
var IsPropertyKey = require('./IsPropertyKey');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-deletepropertyorthrow
// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow
module.exports = function DeletePropertyOrThrow(O, P) {
if (Type(O) !== 'Object') {

View File

@@ -8,7 +8,7 @@ var keys = require('object-keys');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-enumerableownnames
// https://262.ecma-international.org/6.0/#sec-enumerableownnames
module.exports = function EnumerableOwnNames(O) {
if (Type(O) !== 'Object') {

View File

@@ -5,7 +5,7 @@ var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor
module.exports = function FromPropertyDescriptor(Desc) {
if (typeof Desc !== 'undefined') {

View File

@@ -9,7 +9,7 @@ var inspect = require('object-inspect');
var IsPropertyKey = require('./IsPropertyKey');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-get-o-p
// https://262.ecma-international.org/6.0/#sec-get-o-p
module.exports = function Get(O, P) {
// 7.3.1.1

View File

@@ -11,7 +11,7 @@ var GetMethod = require('./GetMethod');
var IsArray = require('./IsArray');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-getiterator
// https://262.ecma-international.org/6.0/#sec-getiterator
module.exports = function GetIterator(obj, method) {
var actualMethod = method;

View File

@@ -8,9 +8,9 @@ var GetV = require('./GetV');
var IsCallable = require('./IsCallable');
var IsPropertyKey = require('./IsPropertyKey');
var debug = require('object-inspect');
var inspect = require('object-inspect');
// https://ecma-international.org/ecma-262/6.0/#sec-getmethod
// https://262.ecma-international.org/6.0/#sec-getmethod
module.exports = function GetMethod(O, P) {
// 7.3.9.1
@@ -28,7 +28,7 @@ module.exports = function GetMethod(O, P) {
// 7.3.9.5
if (!IsCallable(func)) {
throw new $TypeError(P + ' is not a function: ' + debug(func));
throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func));
}
// 7.3.9.6

View File

@@ -12,7 +12,7 @@ var keys = require('object-keys');
var esType = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-getownpropertykeys
// https://262.ecma-international.org/6.0/#sec-getownpropertykeys
module.exports = function GetOwnPropertyKeys(O, Type) {
if (esType(O) !== 'Object') {

View File

@@ -10,10 +10,13 @@ var Get = require('./Get');
var IsConstructor = require('./IsConstructor');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-getprototypefromconstructor
// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor
module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) {
var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic
if (Type(intrinsic) !== 'Object') {
throw new $TypeError('intrinsicDefaultProto must be an object');
}
if (!IsConstructor(constructor)) {
throw new $TypeError('Assertion failed: `constructor` must be a constructor');
}

Some files were not shown because too many files have changed in this diff Show More