Socket
Socket
Sign inDemoInstall

strtok3

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strtok3 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.3

.nyc_output/b096d0fda0c395ce1809bce7d3306b9d.json

10

lib/AbstractTokenizer.d.ts

@@ -7,3 +7,11 @@ /// <reference types="node" />

private numBuffer;
abstract readBuffer(buffer: Buffer, offset: number, length: number, position: number): Promise<number>;
/**
* Read buffer from tokenizer
* @param buffer
* @param offset is the offset in the buffer to start writing at; if not provided, start at 0
* @param length is an integer specifying the number of bytes to read
* @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
* @returns {Promise<TResult|number>}
*/
abstract readBuffer(buffer: Buffer | Uint8Array, offset?: number, length?: number, position?: number): Promise<number>;
readToken<T>(token: IGetToken<T>, position?: number | null): Promise<T>;

@@ -10,0 +18,0 @@ readNumber(token: IToken<number>): Promise<number>;

@@ -10,3 +10,11 @@ import {IGetToken, IToken} from 'token-types';

public abstract readBuffer(buffer: Buffer, offset: number, length: number, position: number): Promise<number>;
/**
* Read buffer from tokenizer
* @param buffer
* @param offset is the offset in the buffer to start writing at; if not provided, start at 0
* @param length is an integer specifying the number of bytes to read
* @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
* @returns {Promise<TResult|number>}
*/
public abstract readBuffer(buffer: Buffer | Uint8Array, offset?: number, length?: number, position?: number): Promise<number>;

@@ -13,0 +21,0 @@ public readToken<T>(token: IGetToken<T>, position: number | null = null): Promise<T> {

@@ -8,4 +8,12 @@ /// <reference types="node" />

constructor(fd: number, fileSize?: number);
readBuffer(buffer: Buffer, offset: number, length: number, position?: number): Promise<number>;
/**
* Read buffer from file
* @param buffer
* @param offset is the offset in the buffer to start writing at; if not provided, start at 0
* @param length is an integer specifying the number of bytes to read, of not provided the buffer length will be used
* @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
* @returns Promise number of bytes read
*/
readBuffer(buffer: Buffer, offset?: number, length?: number, position?: number): Promise<number>;
/**
* @param length Number of bytes to ignore

@@ -12,0 +20,0 @@ */

19

lib/FileTokenizer.js

@@ -25,2 +25,10 @@ "use strict";

}
/**
* Read buffer from file
* @param buffer
* @param offset is the offset in the buffer to start writing at; if not provided, start at 0
* @param length is an integer specifying the number of bytes to read, of not provided the buffer length will be used
* @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
* @returns Promise number of bytes read
*/
FileTokenizer.prototype.readBuffer = function (buffer, offset, length, position) {

@@ -31,8 +39,11 @@ var _this = this;

}
return fs.read(this.fd, buffer, offset, length, this.fileOffset).then(function (bytesRead) {
if (bytesRead < length)
if (!length) {
length = buffer.length;
}
return fs.read(this.fd, buffer, offset, length, this.fileOffset).then(function (res) {
if (res.bytesRead < length)
throw _1.EndOfFile;
_this.fileOffset += bytesRead;
_this.fileOffset += res.bytesRead;
// debug("Read:" + buffer.slice(offset, length).toString("hex"));
return bytesRead;
return res.bytesRead;
});

@@ -39,0 +50,0 @@ };

@@ -13,3 +13,11 @@ import {AbstractTokenizer} from "./AbstractTokenizer";

public readBuffer(buffer: Buffer, offset: number, length: number, position?: number): Promise<number> {
/**
* Read buffer from file
* @param buffer
* @param offset is the offset in the buffer to start writing at; if not provided, start at 0
* @param length is an integer specifying the number of bytes to read, of not provided the buffer length will be used
* @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
* @returns Promise number of bytes read
*/
public readBuffer(buffer: Buffer, offset?: number, length?: number, position?: number): Promise<number> {

@@ -20,10 +28,14 @@ if (position) {

return (fs.read(this.fd, buffer, offset, length, this.fileOffset) as any).then((bytesRead) => { // ToDo: looks like wrong return type is defined in fs.read
if (bytesRead < length)
if (!length) {
length = buffer.length;
}
return (fs.read(this.fd, buffer, offset, length, this.fileOffset) as any).then((res) => {
if (res.bytesRead < length)
throw EndOfFile;
this.fileOffset += bytesRead;
this.fileOffset += res.bytesRead;
// debug("Read:" + buffer.slice(offset, length).toString("hex"));
return bytesRead;
return res.bytesRead;
});

@@ -30,0 +42,0 @@ }

@@ -7,4 +7,12 @@ /// <reference types="node" />

constructor(stream: Stream.Readable, fileSize?: number);
readBuffer(buffer: Buffer, offset: number, length: number, position?: number): Promise<number>;
/**
* Read buffer from stream
* @param buffer
* @param offset is the offset in the buffer to start writing at; if not provided, start at 0
* @param length is an integer specifying the number of bytes to read
* @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
* @returns Promise number of bytes read
*/
readBuffer(buffer: Buffer | Uint8Array, offset?: number, length?: number, position?: number): Promise<number>;
ignore(length: number): Promise<void>;
}

@@ -24,4 +24,14 @@ "use strict";

}
/**
* Read buffer from stream
* @param buffer
* @param offset is the offset in the buffer to start writing at; if not provided, start at 0
* @param length is an integer specifying the number of bytes to read
* @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
* @returns Promise number of bytes read
*/
ReadStreamTokenizer.prototype.readBuffer = function (buffer, offset, length, position) {
if (position === void 0) { position = null; }
if (!length) {
length = buffer.length;
}
return this.streamReader.read(buffer, offset, length, position) // ToDo: looks like wrong return type is defined in fs.read

@@ -28,0 +38,0 @@ .catch(function (err) {

@@ -16,3 +16,16 @@ import {AbstractTokenizer} from "./AbstractTokenizer";

public readBuffer(buffer: Buffer, offset: number, length: number, position: number = null): Promise<number> {
/**
* Read buffer from stream
* @param buffer
* @param offset is the offset in the buffer to start writing at; if not provided, start at 0
* @param length is an integer specifying the number of bytes to read
* @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
* @returns Promise number of bytes read
*/
public readBuffer(buffer: Buffer | Uint8Array, offset?: number, length?: number, position?: number): Promise<number> {
if (!length) {
length = buffer.length;
}
return this.streamReader.read(buffer, offset, length, position) // ToDo: looks like wrong return type is defined in fs.read

@@ -19,0 +32,0 @@ .catch((err) => {

{
"name": "strtok3",
"version": "1.0.1",
"version": "1.0.3",
"description": "A promise based streaming tokenizer",

@@ -15,3 +15,4 @@ "author": {

"cover-test": "nyc npm run test",
"coveralls": "npm run cover-test && nyc report --reporter=text-lcov | coveralls"
"coveralls": "npm run cover-test && nyc report --reporter=text-lcov | coveralls",
"start": "npm run compile && npm run lint && npm run cover-test"
},

@@ -36,9 +37,8 @@ "engines": {

"@types/mocha": "^2.2.41",
"@types/node": "^7.0.37",
"@types/node": "^8.0.13",
"chai": "^4.1.0",
"coveralls": "^2.13.1",
"debug": "^2.6.8",
"gulp-istanbul": "^1.1.2",
"mocha": "^3.4.2",
"nyc": "^11.0.3",
"nyc": "^11.1.0",
"ts-node": "^3.2.0",

@@ -50,4 +50,4 @@ "tslint": "^5.5.0",

"es6-promise": "^4.1.1",
"fs-extra": "^3.0.1",
"then-read-stream": "^0.1.0",
"fs-extra": "^4.0.0",
"then-read-stream": "^0.9.1",
"token-types": "^0.1.2"

@@ -54,0 +54,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 too big to display

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