Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multipasta

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multipasta - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

20

dist/cjs/internal/search.js

@@ -7,2 +7,20 @@ "use strict";

exports.make = make;
function makeMatcher(needle, needleFirstVariationIndex) {
const needleIndexes = [];
const needleChars = [];
for (let i = 0; i < needle.length; i++) {
if (i === 0 || i === needleFirstVariationIndex) continue;
needleIndexes.push(i);
needleChars.push(needle[i]);
}
const needleIndexesLen = needleIndexes.length;
return function exactMatch(chunk, start) {
for (let i = 0; i < needleIndexesLen; i++) {
if (chunk[start + needleIndexes[i]] !== needleChars[i]) {
return false;
}
}
return true;
};
}
function noopMatch(_, __) {

@@ -22,3 +40,3 @@ return false;

const needleFirstVariation = needle[needleFirstVariationIndex];
const exactMatch = "Buffer" in globalThis ? noopMatch : new Function("chunk", "start", "return " + [...needle].filter((_, i) => i !== 0 || i !== needleFirstVariationIndex).map((b, i) => `chunk[start + ${i}] === ${b}`).join(" && "));
const exactMatch = typeof Buffer === "function" ? noopMatch : makeMatcher(needle, needleFirstVariationIndex);
return {

@@ -25,0 +43,0 @@ needle,

@@ -0,1 +1,19 @@

function makeMatcher(needle, needleFirstVariationIndex) {
const needleIndexes = [];
const needleChars = [];
for (let i = 0; i < needle.length; i++) {
if (i === 0 || i === needleFirstVariationIndex) continue;
needleIndexes.push(i);
needleChars.push(needle[i]);
}
const needleIndexesLen = needleIndexes.length;
return function exactMatch(chunk, start) {
for (let i = 0; i < needleIndexesLen; i++) {
if (chunk[start + needleIndexes[i]] !== needleChars[i]) {
return false;
}
}
return true;
};
}
function noopMatch(_, __) {

@@ -15,3 +33,3 @@ return false;

const needleFirstVariation = needle[needleFirstVariationIndex];
const exactMatch = "Buffer" in globalThis ? noopMatch : new Function("chunk", "start", "return " + [...needle].filter((_, i) => i !== 0 || i !== needleFirstVariationIndex).map((b, i) => `chunk[start + ${i}] === ${b}`).join(" && "));
const exactMatch = typeof Buffer === "function" ? noopMatch : makeMatcher(needle, needleFirstVariationIndex);
return {

@@ -18,0 +36,0 @@ needle,

2

package.json
{
"name": "multipasta",
"version": "0.2.1",
"version": "0.2.2",
"description": "",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -15,2 +15,21 @@ interface SearchState {

function makeMatcher(needle: Uint8Array, needleFirstVariationIndex: number) {
const needleIndexes: Array<number> = []
const needleChars: Array<number> = []
for (let i = 0; i < needle.length; i++) {
if (i === 0 || i === needleFirstVariationIndex) continue
needleIndexes.push(i)
needleChars.push(needle[i])
}
const needleIndexesLen = needleIndexes.length
return function exactMatch(chunk: Uint8Array, start: number): boolean {
for (let i = 0; i < needleIndexesLen; i++) {
if (chunk[start + needleIndexes[i]] !== needleChars[i]) {
return false
}
}
return true
}
}
function noopMatch(_: Uint8Array, __: number): boolean {

@@ -35,13 +54,5 @@ return false

const exactMatch =
"Buffer" in globalThis
typeof Buffer === "function"
? noopMatch
: (new Function(
"chunk",
"start",
"return " +
[...needle]
.filter((_, i) => i !== 0 || i !== needleFirstVariationIndex)
.map((b, i) => `chunk[start + ${i}] === ${b}`)
.join(" && "),
) as (chunk: Uint8Array, start: number) => boolean)
: makeMatcher(needle, needleFirstVariationIndex)

@@ -48,0 +59,0 @@ return {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc