Comparing version 0.7.1 to 0.7.2
{ | ||
"name": "lexing", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Regex-based lexer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import { Source } from './index'; | ||
export interface Buffer { | ||
toString(encoding?: string, start?: number, end?: number): string; | ||
slice(start?: number, end?: number): Buffer; | ||
length: number; | ||
} | ||
/** | ||
@@ -3,0 +8,0 @@ Starting at fromIndex (defaults to 0), read until we find `needle`. |
@@ -1,2 +0,1 @@ | ||
var index_1 = require('./index'); | ||
var buffer_1 = require('./buffer'); | ||
@@ -12,8 +11,8 @@ /** | ||
if (BLOCK_SIZE === void 0) { BLOCK_SIZE = 1024; } | ||
var needle = new index_1.Buffer(searchValue); | ||
var needle = new Buffer(searchValue); | ||
var position = fromIndex; | ||
var haystack = new index_1.Buffer(0); | ||
var haystack = new Buffer(0); | ||
var haystack_file_position = position; | ||
var haystack_search_offset = 0; | ||
var block_buffer = new index_1.Buffer(BLOCK_SIZE); | ||
var block_buffer = new Buffer(BLOCK_SIZE); | ||
var bytesRead = BLOCK_SIZE; | ||
@@ -31,3 +30,3 @@ // exit loop once we read fewer bytes than intended (indicating EOF) | ||
// at the end, so only read up to the readBytes mark | ||
haystack = index_1.Buffer.concat([haystack, block_buffer], haystack.length + bytesRead); | ||
haystack = Buffer.concat([haystack, block_buffer], haystack.length + bytesRead); | ||
// TODO: only start looking in the haystack (`buffer`) at the old | ||
@@ -55,5 +54,5 @@ // offset, backtracking by needle.length in case there's a partial match | ||
if (BLOCK_SIZE === void 0) { BLOCK_SIZE = 1024; } | ||
var needle = new index_1.Buffer(searchValue); | ||
var needle = new Buffer(searchValue); | ||
var position = fromIndex; | ||
var haystack = new index_1.Buffer(0); | ||
var haystack = new Buffer(0); | ||
// haystack's position within file is always equal to `position` | ||
@@ -64,3 +63,3 @@ // exit loop once we reach the beginning of the file. | ||
var block_buffer = source.readBuffer(BLOCK_SIZE, position); | ||
haystack = index_1.Buffer.concat([block_buffer, haystack]); | ||
haystack = Buffer.concat([block_buffer, haystack]); | ||
// TODO: only start looking in the haystack (`buffer`) at the old | ||
@@ -67,0 +66,0 @@ // offset, backtracking by needle.length in case there's a partial match |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53620
1160