Socket
Socket
Sign inDemoInstall

split

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

split - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

6

index.js

@@ -39,4 +39,4 @@ //filter will reemit the data if cb(err,pass) pass is truthy

function next (stream, buffer) {
var pieces = (soFar + buffer).split(matcher)
function next (stream, buffer) {
var pieces = ((soFar != null ? soFar : '') + buffer).split(matcher)
soFar = pieces.pop()

@@ -57,3 +57,3 @@

function () {
if(decoder.end)
if(decoder.end)
next(this, decoder.end())

@@ -60,0 +60,0 @@ if(soFar != null)

{
"name": "split",
"version": "0.3.2",
"version": "0.3.3",
"license": "MIT",

@@ -16,6 +16,7 @@ "description": "split a Text Stream into a Line Stream",

"asynct": "*",
"event-stream": "~3.0.2",
"it-is": "1",
"stream-spec": "~0.2",
"ubelt": "~2.9",
"stream-spec": "~0.2",
"event-stream": "~3.0.2"
"string-to-stream": "~1.0.0"
},

@@ -22,0 +23,0 @@ "scripts": {

@@ -8,3 +8,6 @@ var es = require('event-stream')

, Stream = require('stream').Stream
, Readable = require('stream').Readable
, spec = require('stream-spec')
, through = require('through')
, stringStream = require('string-to-stream')

@@ -20,3 +23,3 @@ exports ['split() works like String#split'] = function (test) {

var a = new Stream ()
a.write = function (l) {

@@ -44,6 +47,6 @@ actual.push(l.trim())

a.writable = true
fs.createReadStream(readme, {flags: 'r'}).pipe(cs)
cs.pipe(a)
cs.pipe(a)
}

@@ -60,3 +63,3 @@

var a = new Stream ()
a.write = function (l) {

@@ -84,7 +87,56 @@ actual.push(l.trim())

a.writable = true
fs.createReadStream(readme, {flags: 'r'}).pipe(cs)
cs.pipe(a)
cs.pipe(a)
}
exports ['split() works with empty string chunks'] = function (test) {
var str = ' foo'
, expected = str.split(/[\s]*/).reduce(splitBy(/[\s]*/), [])
, cs1 = split(/[\s]*/)
, cs2 = split(/[\s]*/)
, actual = []
, ended = false
, x = spec(cs1).through()
, y = spec(cs2).through()
var a = new Stream ()
a.write = function (l) {
actual.push(l.trim())
}
a.end = function () {
ended = true
expected.forEach(function (v,k) {
//String.split will append an empty string ''
//if the string ends in a split pattern.
//es.split doesn't which was breaking this test.
//clearly, appending the empty string is correct.
//tests are passing though. which is the current job.
if(v)
it(actual[k]).like(v)
})
//give the stream time to close
process.nextTick(function () {
test.done()
x.validate()
y.validate()
})
}
a.writable = true
cs1.pipe(cs2)
cs2.pipe(a)
cs1.write(str)
cs1.end()
}
function splitBy (delimeter) {
return function (arr, piece) {
return arr.concat(piece.split(delimeter))
}
}
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