Socket
Socket
Sign inDemoInstall

split2

Package Overview
Dependencies
5
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.1 to 3.2.0

.nyc_output/72f8c84c-0fde-46af-9e13-110b40a39bfa.json

12

index.js

@@ -43,3 +43,7 @@ /*

for (var i = 0; i < list.length; i++) {
push(this, this.mapper(list[i]))
try {
push(this, this.mapper(list[i]))
} catch (error) {
return cb(error)
}
}

@@ -58,3 +62,7 @@

if (this[kLast]) {
push(this, this.mapper(this[kLast]))
try {
push(this, this.mapper(this[kLast]))
} catch (error) {
return cb(error)
}
}

@@ -61,0 +69,0 @@

19

package.json
{
"name": "split2",
"version": "3.1.1",
"version": "3.2.0",
"description": "split a Text Stream into a Line Stream, using Stream 3",
"main": "index.js",
"scripts": {
"test": "standard && tap -b test.js"
"lint": "standard --verbose",
"unit": "nyc --lines 100 --branches 100 --functions 100 --check-coverage --reporter=text tape test.js",
"coverage": "nyc --reporter=html --reporter=cobertura --reporter=text tape test/test.js",
"test:report": "npm run lint && npm run unit:report",
"test": "npm run lint && npm run unit",
"legacy": "tape test.js"
},

@@ -26,15 +31,11 @@ "pre-commit": [

"fastbench": "^1.0.0",
"nyc": "^15.0.1",
"pre-commit": "^1.1.2",
"safe-buffer": "^5.1.1",
"standard": "^12.0.0",
"tap": "^12.0.0"
"standard": "^14.0.0",
"tape": "^5.0.0"
},
"dependencies": {
"readable-stream": "^3.0.0"
},
"greenkeeper": {
"ignore": [
"tap"
]
}
}
# Split2(matcher, mapper, options)
[![Greenkeeper badge](https://badges.greenkeeper.io/mcollina/split2.svg)](https://greenkeeper.io/)
![ci](https://github.com/mcollina/split2/workflows/ci/badge.svg)
[![build status](https://secure.travis-ci.org/mcollina/split2.svg)](http://travis-ci.org/mcollina/split2)
Break up a stream and reassemble it so that each line is a chunk.

@@ -65,6 +63,9 @@ `split2` is inspired by [@dominictarr](https://github.com/dominictarr) [`split`](https://github.com/dominictarr/split) module,

})
.on("error", function(error) => {
//handling parsing errors
})
```
However, in [@dominictarr](https://github.com/dominictarr) [`split`](https://github.com/dominictarr/split) the mapper
is wrapped in a try-catch, while here it is not: if your parsing logic can throw, wrap it yourself.
is wrapped in a try-catch, while here it is not: if your parsing logic can throw, wrap it yourself. Otherwise, you can also use the stream error handling when mapper function throw.

@@ -71,0 +72,0 @@ # Benchmark

'use strict'
var test = require('tap').test
var test = require('tape')
var split = require('./')

@@ -155,3 +155,3 @@ var callback = require('callback-stream')

var input = split(function (line) {})
var input = split(function (line) { })

@@ -169,3 +169,3 @@ input.pipe(strcb(function (err, list) {

var input = split(function (line) {})
var input = split(function (line) { })

@@ -366,1 +366,30 @@ input.on('close', function () {

})
test('mapper throws flush', function (t) {
t.plan(1)
var error = new Error()
var input = split(function () {
throw error
})
input.on('error', (err, list) => {
t.same(err, error)
})
input.end('hello')
})
test('mapper throws on transform', function (t) {
t.plan(2)
var error = new Error()
var input = split(function (l) {
throw error
})
input.on('error', (err) => {
t.same(err, error)
})
input.write('a')
input.write('\n')
input.end('b')
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc