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

multipasta

Package Overview
Dependencies
Maintainers
1
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.1.11 to 0.1.12

60

dist/cjs/internal/search.js

@@ -117,2 +117,60 @@ "use strict";

}
function writeBuffer(chunk_) {
let chunk = Buffer.isBuffer(chunk_) ? chunk_ : Buffer.from(chunk_);
let chunkLength = chunk.length;
if (chunkLength < state.needleLength) {
if (state.previousChunk === undefined) {
state.previousChunk = chunk;
state.previousChunkLength = chunkLength;
return;
}
}
if (state.previousChunk !== undefined) {
const newChunk = Buffer.allocUnsafe(state.previousChunkLength + chunkLength);
newChunk.set(state.previousChunk);
newChunk.set(chunk, state.previousChunkLength);
chunk = newChunk;
chunkLength = state.previousChunkLength + chunkLength;
state.previousChunk = undefined;
}
let pos = 0;
while (pos < chunkLength) {
const match = chunk.indexOf(state.needle, pos);
if (match > -1) {
if (match > pos) {
callback(state.matchIndex, chunk.subarray(pos, match));
}
state.matchIndex += 1;
pos = match + state.needleLength;
} else if (chunk[chunkLength - 1] in state.indexes) {
const indexes = state.indexes[chunk[chunkLength - 1]];
let earliestIndex = -1;
for (let i = 0, len = indexes.length; i < len; i++) {
const index = indexes[i];
if (chunk[chunkLength - 1 - index] === state.firstByte && i > earliestIndex) {
earliestIndex = index;
}
}
if (earliestIndex === -1) {
if (pos === 0) {
callback(state.matchIndex, chunk);
} else {
callback(state.matchIndex, chunk.subarray(pos));
}
} else {
callback(state.matchIndex, chunk.subarray(pos, chunkLength - 1 - earliestIndex));
state.previousChunk = chunk.subarray(chunkLength - 1 - earliestIndex);
state.previousChunkLength = earliestIndex + 1;
}
break;
} else {
if (pos === 0) {
callback(state.matchIndex, chunk);
} else {
callback(state.matchIndex, chunk.subarray(pos));
}
break;
}
}
}
function end() {

@@ -127,3 +185,3 @@ if (state.previousChunk !== undefined && state.previousChunk !== seed) {

return {
write,
write: "Buffer" in globalThis ? writeBuffer : write,
end

@@ -130,0 +188,0 @@ };

6

dist/cjs/web.js

@@ -45,3 +45,2 @@ "use strict";

let finished = false;
let writeController;
const parser = MP.make({

@@ -100,6 +99,4 @@ ...config,

onError(error_) {
if (error !== undefined) return;
error = error_;
if (writeController !== undefined) {
writeController.error(error);
}
if (readResolve !== undefined) readResolve();

@@ -114,3 +111,2 @@ },

write(chunk, controller) {
writeController = controller;
parser.write(chunk);

@@ -117,0 +113,0 @@ },

@@ -111,2 +111,60 @@ function makeState(needle_) {

}
function writeBuffer(chunk_) {
let chunk = Buffer.isBuffer(chunk_) ? chunk_ : Buffer.from(chunk_);
let chunkLength = chunk.length;
if (chunkLength < state.needleLength) {
if (state.previousChunk === undefined) {
state.previousChunk = chunk;
state.previousChunkLength = chunkLength;
return;
}
}
if (state.previousChunk !== undefined) {
const newChunk = Buffer.allocUnsafe(state.previousChunkLength + chunkLength);
newChunk.set(state.previousChunk);
newChunk.set(chunk, state.previousChunkLength);
chunk = newChunk;
chunkLength = state.previousChunkLength + chunkLength;
state.previousChunk = undefined;
}
let pos = 0;
while (pos < chunkLength) {
const match = chunk.indexOf(state.needle, pos);
if (match > -1) {
if (match > pos) {
callback(state.matchIndex, chunk.subarray(pos, match));
}
state.matchIndex += 1;
pos = match + state.needleLength;
} else if (chunk[chunkLength - 1] in state.indexes) {
const indexes = state.indexes[chunk[chunkLength - 1]];
let earliestIndex = -1;
for (let i = 0, len = indexes.length; i < len; i++) {
const index = indexes[i];
if (chunk[chunkLength - 1 - index] === state.firstByte && i > earliestIndex) {
earliestIndex = index;
}
}
if (earliestIndex === -1) {
if (pos === 0) {
callback(state.matchIndex, chunk);
} else {
callback(state.matchIndex, chunk.subarray(pos));
}
} else {
callback(state.matchIndex, chunk.subarray(pos, chunkLength - 1 - earliestIndex));
state.previousChunk = chunk.subarray(chunkLength - 1 - earliestIndex);
state.previousChunkLength = earliestIndex + 1;
}
break;
} else {
if (pos === 0) {
callback(state.matchIndex, chunk);
} else {
callback(state.matchIndex, chunk.subarray(pos));
}
break;
}
}
}
function end() {

@@ -121,3 +179,3 @@ if (state.previousChunk !== undefined && state.previousChunk !== seed) {

return {
write,
write: "Buffer" in globalThis ? writeBuffer : write,
end

@@ -124,0 +182,0 @@ };

@@ -9,3 +9,2 @@ import * as MP from "./index.js";

let finished = false;
let writeController;
const parser = MP.make({

@@ -64,6 +63,4 @@ ...config,

onError(error_) {
if (error !== undefined) return;
error = error_;
if (writeController !== undefined) {
writeController.error(error);
}
if (readResolve !== undefined) readResolve();

@@ -78,3 +75,2 @@ },

write(chunk, controller) {
writeController = controller;
parser.write(chunk);

@@ -81,0 +77,0 @@ },

{
"name": "multipasta",
"version": "0.1.11",
"version": "0.1.12",
"description": "",

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

@@ -169,2 +169,73 @@ interface SearchState {

function writeBuffer(chunk_: Buffer | Uint8Array): void {
let chunk = Buffer.isBuffer(chunk_) ? chunk_ : Buffer.from(chunk_)
let chunkLength = chunk.length
if (chunkLength < state.needleLength) {
if (state.previousChunk === undefined) {
state.previousChunk = chunk
state.previousChunkLength = chunkLength
return
}
}
if (state.previousChunk !== undefined) {
const newChunk = Buffer.allocUnsafe(
state.previousChunkLength + chunkLength,
)
newChunk.set(state.previousChunk)
newChunk.set(chunk, state.previousChunkLength)
chunk = newChunk
chunkLength = state.previousChunkLength + chunkLength
state.previousChunk = undefined
}
let pos = 0
while (pos < chunkLength) {
const match = chunk.indexOf(state.needle, pos)
if (match > -1) {
if (match > pos) {
callback(state.matchIndex, chunk.subarray(pos, match))
}
state.matchIndex += 1
pos = match + state.needleLength
} else if (chunk[chunkLength - 1] in state.indexes) {
const indexes = state.indexes[chunk[chunkLength - 1]]
let earliestIndex = -1
for (let i = 0, len = indexes.length; i < len; i++) {
const index = indexes[i]
if (
chunk[chunkLength - 1 - index] === state.firstByte &&
i > earliestIndex
) {
earliestIndex = index
}
}
if (earliestIndex === -1) {
if (pos === 0) {
callback(state.matchIndex, chunk)
} else {
callback(state.matchIndex, chunk.subarray(pos))
}
} else {
callback(
state.matchIndex,
chunk.subarray(pos, chunkLength - 1 - earliestIndex),
)
state.previousChunk = chunk.subarray(chunkLength - 1 - earliestIndex)
state.previousChunkLength = earliestIndex + 1
}
break
} else {
if (pos === 0) {
callback(state.matchIndex, chunk)
} else {
callback(state.matchIndex, chunk.subarray(pos))
}
break
}
}
}
function end(): void {

@@ -180,3 +251,6 @@ if (state.previousChunk !== undefined && state.previousChunk !== seed) {

return { write, end } as const
return {
write: "Buffer" in globalThis ? writeBuffer : write,
end,
} as const
}

@@ -35,3 +35,2 @@ import * as MP from "./index.js"

let finished = false
let writeController: WritableStreamDefaultController | undefined

@@ -86,6 +85,4 @@ const parser = MP.make({

onError(error_) {
if (error !== undefined) return
error = error_
if (writeController !== undefined) {
writeController.error(error)
}
if (readResolve !== undefined) readResolve()

@@ -102,3 +99,2 @@ },

write(chunk, controller) {
writeController = controller
parser.write(chunk)

@@ -105,0 +101,0 @@ },

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

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