This commit is contained in:
2026-03-03 15:23:00 +00:00
parent 5e3726de39
commit 8e223bfbec
3689 changed files with 955330 additions and 1011 deletions

11
node_modules/@hapi/nigel/LICENSE.md generated vendored Executable file
View File

@@ -0,0 +1,11 @@
Copyright (c) 2014-2022, Project contributors
Copyright (c) 2014-2020, Sideway Inc
Copyright (c) 2014, Walmart.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

15
node_modules/@hapi/nigel/README.md generated vendored Normal file
View File

@@ -0,0 +1,15 @@
# @hapi/nigel
#### Boyer-Moore-Horspool algorithms
**nigel** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) they work even better together.
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
## Useful resources
- [Documentation and API](https://hapi.dev/family/nigel/)
- [Versions status](https://hapi.dev/resources/status/#nigel) (builds, dependencies, node versions, licenses, eol)
- [Changelog](https://hapi.dev/family/nigel/changelog/)
- [Project policies](https://hapi.dev/policies/)
- [Free and commercial support options](https://hapi.dev/support/)

184
node_modules/@hapi/nigel/lib/index.js generated vendored Executable file
View File

@@ -0,0 +1,184 @@
'use strict';
const Stream = require('stream');
const Hoek = require('@hapi/hoek');
const { Vise } = require('@hapi/vise');
const internals = {};
exports.compile = function (needle) {
Hoek.assert(needle?.length, 'Missing needle');
Hoek.assert(Buffer.isBuffer(needle), 'Needle must be a buffer');
const profile = {
value: needle,
lastPos: needle.length - 1,
last: needle[needle.length - 1],
length: needle.length,
badCharShift: Buffer.alloc(256) // Lookup table of how many characters can be skipped for each match
};
for (let i = 0; i < 256; ++i) {
profile.badCharShift[i] = profile.length; // Defaults to the full length of the needle
}
const last = profile.length - 1;
for (let i = 0; i < last; ++i) { // For each character in the needle (skip last since its position is already the default)
profile.badCharShift[profile.value[i]] = last - i;
}
return profile;
};
exports.horspool = function (haystack, needle, start) {
Hoek.assert(haystack, 'Missing haystack');
needle = (needle.badCharShift ? needle : exports.compile(needle));
start = start ?? 0;
for (let i = start; i <= haystack.length - needle.length;) { // Has enough room to fit the entire needle
const lastChar = haystack.readUInt8(i + needle.lastPos);
if (lastChar === needle.last &&
internals.startsWith(haystack, needle, i)) {
return i;
}
i += needle.badCharShift[lastChar]; // Jump to the next possible position based on last character location in needle
}
return -1;
};
internals.startsWith = function (haystack, needle, pos) {
if (haystack.startsWith) {
return haystack.startsWith(needle.value, pos, needle.lastPos);
}
for (let i = 0; i < needle.lastPos; ++i) {
if (needle.value[i] !== haystack.readUInt8(pos + i)) {
return false;
}
}
return true;
};
exports.all = function (haystack, needle, start) {
needle = exports.compile(needle);
start = start ?? 0;
const matches = [];
for (let i = start; i !== -1 && i < haystack.length;) {
i = exports.horspool(haystack, needle, i);
if (i !== -1) {
matches.push(i);
i += needle.length;
}
}
return matches;
};
internals._indexOf = function (haystack, needle) {
Hoek.assert(haystack, 'Missing haystack');
for (let i = 0; i <= haystack.length - needle.length; ++i) { // Has enough room to fit the entire needle
if (haystack.startsWith(needle.value, i)) {
return i;
}
}
return -1;
};
exports.Stream = class extends Stream.Writable {
constructor(needle) {
super();
this.needle(needle);
this._haystack = new Vise();
this._indexOf = this._needle.length > 2 ? exports.horspool : internals._indexOf;
this.on('finish', () => {
// Flush out the remainder
const chunks = this._haystack.chunks();
for (let i = 0; i < chunks.length; ++i) {
this.emit('haystack', chunks[i]);
}
});
}
needle(needle) {
this._needle = exports.compile(needle);
}
_write(chunk, encoding, next) {
this._haystack.push(chunk);
let match = this._indexOf(this._haystack, this._needle);
if (match === -1 &&
chunk.length >= this._needle.length) {
this._flush(this._haystack.length - chunk.length);
}
while (match !== -1) {
this._flush(match);
this._haystack.shift(this._needle.length);
this.emit('needle');
match = this._indexOf(this._haystack, this._needle);
}
if (this._haystack.length) {
const notChecked = this._haystack.length - this._needle.length + 1; // Not enough space for Horspool
let i = notChecked;
for (; i < this._haystack.length; ++i) {
if (this._haystack.startsWith(this._needle.value, i, this._haystack.length - i)) {
break;
}
}
this._flush(i);
}
return next();
}
_flush(pos) {
const chunks = this._haystack.shift(pos);
for (let i = 0; i < chunks.length; ++i) {
this.emit('haystack', chunks[i]);
}
}
flush() {
const chunks = this._haystack.shift(this._haystack.length);
for (let i = 0; i < chunks.length; ++i) {
this.emit('haystack', chunks[i]);
}
}
};

40
node_modules/@hapi/nigel/package.json generated vendored Executable file
View File

@@ -0,0 +1,40 @@
{
"name": "@hapi/nigel",
"description": "Boyer-Moore-Horspool algorithms",
"version": "5.0.1",
"repository": "git://github.com/hapijs/nigel",
"main": "lib/index.js",
"engines": {
"node": ">=14.0.0"
},
"files": [
"lib"
],
"keywords": [
"boyer-moore-horspool",
"algorithms",
"lookup",
"search",
"stream"
],
"eslintConfig": {
"extends": [
"plugin:@hapi/module"
]
},
"dependencies": {
"@hapi/hoek": "^11.0.2",
"@hapi/vise": "^5.0.1"
},
"devDependencies": {
"@hapi/code": "^9.0.3",
"@hapi/eslint-plugin": "*",
"@hapi/lab": "^25.0.1",
"@hapi/teamwork": "^6.0.0"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L",
"test-cov-html": "lab -a @hapi/code -r html -o coverage.html"
},
"license": "BSD-3-Clause"
}