File: options.asynct.js

package info (click to toggle)
node-split 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 120 kB
  • sloc: javascript: 260; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 851 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var it = require('it-is').style('colour')
  , split = require('..')

exports ['maximum buffer limit'] = function (test) {
  var s = split(JSON.parse, null, {
    maxLength: 2
  })
    , caughtError = false
    , rows = []

  s.on('error', function (err) {
    caughtError = true
  })

  s.on('data', function (row) { rows.push(row) })

  s.write('{"a":1}\n{"')
  s.write('{    "')
  it(caughtError).equal(true)

  s.end()
  test.done()
}

exports ['ignore trailing buffers'] = function (test) {
  var s = split(JSON.parse, null, {
    trailing: false
  })
    , caughtError = false
    , rows = []

  s.on('error', function (err) {
    caughtError = true
  })

  s.on('data', function (row) { rows.push(row) })

  s.write('{"a":1}\n{"')
  s.write('{    "')
  s.end()

  it(caughtError).equal(false)
  it(rows).deepEqual([ { a: 1 } ])

  test.done()
}