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

parser-delimiter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parser-delimiter - npm Package Compare versions

Comparing version 0.0.2 to 1.0.0

46

delimiter.js

@@ -1,4 +0,4 @@

'use strict';
const Buffer = require('safe-buffer').Buffer;
const Transform = require('stream').Transform;
'use strict'
const Buffer = require('safe-buffer').Buffer
const Transform = require('stream').Transform
/**

@@ -16,37 +16,37 @@ * A transform stream that emits data each time a byte sequence is received.

class DelimiterParser extends Transform {
constructor(options) {
options = options || {};
super(options);
constructor (options) {
options = options || {}
super(options)
if (options.delimiter === undefined) {
throw new TypeError('"delimiter" is not a bufferable object');
throw new TypeError('"delimiter" is not a bufferable object')
}
if (options.delimiter.length === 0) {
throw new TypeError('"delimiter" has a 0 or undefined length');
throw new TypeError('"delimiter" has a 0 or undefined length')
}
this.includeDelimiter = options.includeDelimiter !== undefined ? options.includeDelimiter : false;
this.delimiter = Buffer.from(options.delimiter);
this.buffer = Buffer.alloc(0);
this.includeDelimiter = options.includeDelimiter !== undefined ? options.includeDelimiter : false
this.delimiter = Buffer.from(options.delimiter)
this.buffer = Buffer.alloc(0)
}
_transform(chunk, encoding, cb) {
let data = Buffer.concat([this.buffer, chunk]);
let position;
_transform (chunk, encoding, cb) {
let data = Buffer.concat([this.buffer, chunk])
let position
while ((position = data.indexOf(this.delimiter)) !== -1) {
this.push(data.slice(0, position + (this.includeDelimiter ? this.delimiter.length : 0)));
data = data.slice(position + this.delimiter.length);
this.push(data.slice(0, position + (this.includeDelimiter ? this.delimiter.length : 0)))
data = data.slice(position + this.delimiter.length)
}
this.buffer = data;
cb();
this.buffer = data
cb()
}
_flush(cb) {
this.push(this.buffer);
this.buffer = Buffer.alloc(0);
cb();
_flush (cb) {
this.push(this.buffer)
this.buffer = Buffer.alloc(0)
cb()
}
};
module.exports = DelimiterParser;
module.exports = DelimiterParser
{
"name": "parser-delimiter",
"main": "regex.js",
"version": "0.0.2",
"main": "delimiter.js",
"version": "1.0.0",
"dependencies": {
"safe-buffer": "^5.1.1"
},
"devDependencies": {
"chai": "^4.1.2",
"docdash": "^0.4.0",
"jsdoc": "^3.5.5"
},
"license": "MIT",

@@ -14,0 +9,0 @@ "repository": {

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