File: common.coffee

package info (click to toggle)
node-xml2js 0.4.23%2B~cs15.4.0%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,380 kB
  • sloc: xml: 117; javascript: 7; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 760 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
global.builder = require('../src/index')
global.assert = require('assert')

global.xml = builder.create
global.doc = builder.begin
global.writer = builder.stringWriter

global.xpath = require('xpath')

global.ok = assert.ok
global.eq = assert.strictEqual
global.err = assert.throws
global.noterr = assert.doesNotThrow
global.isan = (obj, type) ->
  clas = obj.constructor.name
  eq(clas, type)

global.captureStream = (stream) ->
  oldWrite = stream.write
  buf = ''
  stream.write = (chunk, encoding, callback) ->
    buf += chunk.toString()
    # oldWrite.apply(stream, arguments)

  return {
    unhook: ->
      stream.write = oldWrite
    captured: ->
      buf
  }

global.xmleleend = (arg) ->
  builder.create('root', { headless: true }).ele(arg).end()