Einkaufslisten anzeigen, Datenbankeinbindung
This commit is contained in:
		
							
								
								
									
										3
									
								
								express-server/node_modules/split/.npmignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								express-server/node_modules/split/.npmignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
node_modules
 | 
			
		||||
node_modules/*
 | 
			
		||||
npm_debug.log
 | 
			
		||||
							
								
								
									
										3
									
								
								express-server/node_modules/split/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								express-server/node_modules/split/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
language: node_js
 | 
			
		||||
node_js:
 | 
			
		||||
  - "0.10"
 | 
			
		||||
							
								
								
									
										22
									
								
								express-server/node_modules/split/LICENCE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								express-server/node_modules/split/LICENCE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
Copyright (c) 2011 Dominic Tarr
 | 
			
		||||
 | 
			
		||||
Permission is hereby granted, free of charge, 
 | 
			
		||||
to any person obtaining a copy of this software and 
 | 
			
		||||
associated documentation files (the "Software"), to 
 | 
			
		||||
deal in the Software without restriction, including 
 | 
			
		||||
without limitation the rights to use, copy, modify, 
 | 
			
		||||
merge, publish, distribute, sublicense, and/or sell 
 | 
			
		||||
copies of the Software, and to permit persons to whom 
 | 
			
		||||
the Software is furnished to do so, 
 | 
			
		||||
subject to the following conditions:
 | 
			
		||||
 | 
			
		||||
The above copyright notice and this permission notice 
 | 
			
		||||
shall be included in all copies or substantial portions of the Software.
 | 
			
		||||
 | 
			
		||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
 | 
			
		||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
 | 
			
		||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
 | 
			
		||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
 | 
			
		||||
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
 | 
			
		||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 | 
			
		||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
			
		||||
							
								
								
									
										26
									
								
								express-server/node_modules/split/examples/pretty.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								express-server/node_modules/split/examples/pretty.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
 | 
			
		||||
var inspect = require('util').inspect
 | 
			
		||||
var es      = require('event-stream')     //load event-stream
 | 
			
		||||
var split   = require('../')
 | 
			
		||||
 | 
			
		||||
if(!module.parent) {
 | 
			
		||||
  es.pipe(                            //pipe joins streams together
 | 
			
		||||
    process.openStdin(),              //open stdin
 | 
			
		||||
    split(),                       //split stream to break on newlines
 | 
			
		||||
    es.map(function (data, callback) {//turn this async function into a stream
 | 
			
		||||
      var j 
 | 
			
		||||
      try {
 | 
			
		||||
        j = JSON.parse(data)          //try to parse input into json
 | 
			
		||||
      } catch (err) {
 | 
			
		||||
        return callback(null, data)   //if it fails just pass it anyway
 | 
			
		||||
      }
 | 
			
		||||
      callback(null, inspect(j))      //render it nicely
 | 
			
		||||
    }),
 | 
			
		||||
    process.stdout                    // pipe it to stdout !
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
// run this
 | 
			
		||||
// 
 | 
			
		||||
// curl -sS registry.npmjs.org/event-stream | node pretty.js 
 | 
			
		||||
//
 | 
			
		||||
							
								
								
									
										63
									
								
								express-server/node_modules/split/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								express-server/node_modules/split/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
//filter will reemit the data if cb(err,pass) pass is truthy
 | 
			
		||||
 | 
			
		||||
// reduce is more tricky
 | 
			
		||||
// maybe we want to group the reductions or emit progress updates occasionally
 | 
			
		||||
// the most basic reduce just emits one 'data' event after it has recieved 'end'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
var through = require('through')
 | 
			
		||||
var Decoder = require('string_decoder').StringDecoder
 | 
			
		||||
 | 
			
		||||
module.exports = split
 | 
			
		||||
 | 
			
		||||
//TODO pass in a function to map across the lines.
 | 
			
		||||
 | 
			
		||||
function split (matcher, mapper, options) {
 | 
			
		||||
  var decoder = new Decoder()
 | 
			
		||||
  var soFar = ''
 | 
			
		||||
  var maxLength = options && options.maxLength;
 | 
			
		||||
  var trailing = options && options.trailing === false ? false : true
 | 
			
		||||
  if('function' === typeof matcher)
 | 
			
		||||
    mapper = matcher, matcher = null
 | 
			
		||||
  if (!matcher)
 | 
			
		||||
    matcher = /\r?\n/
 | 
			
		||||
 | 
			
		||||
  function emit(stream, piece) {
 | 
			
		||||
    if(mapper) {
 | 
			
		||||
      try {
 | 
			
		||||
        piece = mapper(piece)
 | 
			
		||||
      }
 | 
			
		||||
      catch (err) {
 | 
			
		||||
        return stream.emit('error', err)
 | 
			
		||||
      }
 | 
			
		||||
      if('undefined' !== typeof piece)
 | 
			
		||||
        stream.queue(piece)
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
      stream.queue(piece)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function next (stream, buffer) {
 | 
			
		||||
    var pieces = ((soFar != null ? soFar : '') + buffer).split(matcher)
 | 
			
		||||
    soFar = pieces.pop()
 | 
			
		||||
 | 
			
		||||
    if (maxLength && soFar.length > maxLength)
 | 
			
		||||
      return stream.emit('error', new Error('maximum buffer reached'))
 | 
			
		||||
 | 
			
		||||
    for (var i = 0; i < pieces.length; i++) {
 | 
			
		||||
      var piece = pieces[i]
 | 
			
		||||
      emit(stream, piece)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return through(function (b) {
 | 
			
		||||
    next(this, decoder.write(b))
 | 
			
		||||
  },
 | 
			
		||||
  function () {
 | 
			
		||||
    if(decoder.end)
 | 
			
		||||
      next(this, decoder.end())
 | 
			
		||||
    if(trailing && soFar != null)
 | 
			
		||||
      emit(this, soFar)
 | 
			
		||||
    this.queue(null)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										62
									
								
								express-server/node_modules/split/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								express-server/node_modules/split/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
{
 | 
			
		||||
  "_from": "split@^1.0.0",
 | 
			
		||||
  "_id": "split@1.0.1",
 | 
			
		||||
  "_inBundle": false,
 | 
			
		||||
  "_integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==",
 | 
			
		||||
  "_location": "/split",
 | 
			
		||||
  "_phantomChildren": {},
 | 
			
		||||
  "_requested": {
 | 
			
		||||
    "type": "range",
 | 
			
		||||
    "registry": true,
 | 
			
		||||
    "raw": "split@^1.0.0",
 | 
			
		||||
    "name": "split",
 | 
			
		||||
    "escapedName": "split",
 | 
			
		||||
    "rawSpec": "^1.0.0",
 | 
			
		||||
    "saveSpec": null,
 | 
			
		||||
    "fetchSpec": "^1.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "_requiredBy": [
 | 
			
		||||
    "/pgpass"
 | 
			
		||||
  ],
 | 
			
		||||
  "_resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz",
 | 
			
		||||
  "_shasum": "605bd9be303aa59fb35f9229fbea0ddec9ea07d9",
 | 
			
		||||
  "_spec": "split@^1.0.0",
 | 
			
		||||
  "_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\SmartShopper\\express-server\\node_modules\\pgpass",
 | 
			
		||||
  "author": {
 | 
			
		||||
    "name": "Dominic Tarr",
 | 
			
		||||
    "email": "dominic.tarr@gmail.com",
 | 
			
		||||
    "url": "http://bit.ly/dominictarr"
 | 
			
		||||
  },
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/dominictarr/split/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "bundleDependencies": false,
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "through": "2"
 | 
			
		||||
  },
 | 
			
		||||
  "deprecated": false,
 | 
			
		||||
  "description": "split a Text Stream into a Line Stream",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "asynct": "*",
 | 
			
		||||
    "event-stream": "~3.0.2",
 | 
			
		||||
    "it-is": "1",
 | 
			
		||||
    "stream-spec": "~0.2",
 | 
			
		||||
    "string-to-stream": "~1.0.0",
 | 
			
		||||
    "ubelt": "~2.9"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
    "node": "*"
 | 
			
		||||
  },
 | 
			
		||||
  "homepage": "http://github.com/dominictarr/split",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "name": "split",
 | 
			
		||||
  "optionalDependencies": {},
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git://github.com/dominictarr/split.git"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test": "asynct test/"
 | 
			
		||||
  },
 | 
			
		||||
  "version": "1.0.1"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										72
									
								
								express-server/node_modules/split/readme.markdown
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								express-server/node_modules/split/readme.markdown
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,72 @@
 | 
			
		||||
# Split (matcher)
 | 
			
		||||
 | 
			
		||||
[](http://travis-ci.org/dominictarr/split)
 | 
			
		||||
 | 
			
		||||
Break up a stream and reassemble it so that each line is a chunk. matcher may be a `String`, or a `RegExp`
 | 
			
		||||
 | 
			
		||||
Example, read every line in a file ...
 | 
			
		||||
 | 
			
		||||
``` js
 | 
			
		||||
  fs.createReadStream(file)
 | 
			
		||||
    .pipe(split())
 | 
			
		||||
    .on('data', function (line) {
 | 
			
		||||
      //each chunk now is a separate line!
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
`split` takes the same arguments as `string.split` except it defaults to '/\r?\n/' instead of ',', and the optional `limit` parameter is ignored.
 | 
			
		||||
[String#split](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/split)
 | 
			
		||||
 | 
			
		||||
`split` takes an optional options object on its third argument.
 | 
			
		||||
 | 
			
		||||
``` js
 | 
			
		||||
  split(matcher, mapper, options)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Valid options:
 | 
			
		||||
 | 
			
		||||
* maxLength - The maximum buffer length without seeing a newline or `matcher`,
 | 
			
		||||
  if a single line exceeds this, the split stream will emit an error.
 | 
			
		||||
 | 
			
		||||
``` js
 | 
			
		||||
  split(JSON.parse, null, { maxLength: 2})
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
* trailing - By default the last buffer not delimited by a newline or `matcher` will be emitted. To prevent this set `options.trailing` to `false`.
 | 
			
		||||
 | 
			
		||||
``` js
 | 
			
		||||
  split(JSON.parse, null, { trailing: false })
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## keep matched splitter
 | 
			
		||||
 | 
			
		||||
As with `String#split`, if you split by a regular expression with a matching group,
 | 
			
		||||
the matches will be retained in the collection.
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
stdin
 | 
			
		||||
.pipe(split(/(\r?\n)/))
 | 
			
		||||
... //lines + separators.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# NDJ - Newline Delimited Json
 | 
			
		||||
 | 
			
		||||
`split` accepts a function which transforms each line.
 | 
			
		||||
 | 
			
		||||
``` js
 | 
			
		||||
fs.createReadStream(file)
 | 
			
		||||
  .pipe(split(JSON.parse))
 | 
			
		||||
  .on('data', function (obj) {
 | 
			
		||||
    //each chunk now is a a js object
 | 
			
		||||
  })
 | 
			
		||||
  .on('error', function (err) {
 | 
			
		||||
    //syntax errors will land here
 | 
			
		||||
    //note, this ends the stream.
 | 
			
		||||
  })
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# License
 | 
			
		||||
 | 
			
		||||
MIT
 | 
			
		||||
							
								
								
									
										46
									
								
								express-server/node_modules/split/test/options.asynct.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								express-server/node_modules/split/test/options.asynct.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,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()
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								express-server/node_modules/split/test/partitioned_unicode.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								express-server/node_modules/split/test/partitioned_unicode.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
var it = require('it-is').style('colour')
 | 
			
		||||
  , split = require('..')
 | 
			
		||||
 | 
			
		||||
exports ['split data with partitioned unicode character'] = function (test) {
 | 
			
		||||
  var s = split(/,/g)
 | 
			
		||||
    , caughtError = false
 | 
			
		||||
    , rows = []
 | 
			
		||||
 | 
			
		||||
  s.on('error', function (err) {
 | 
			
		||||
    caughtError = true
 | 
			
		||||
  })
 | 
			
		||||
 
 | 
			
		||||
  s.on('data', function (row) { rows.push(row) })
 | 
			
		||||
 | 
			
		||||
  var x = 'テスト試験今日とても,よい天気で'
 | 
			
		||||
  unicodeData = new Buffer(x);
 | 
			
		||||
 | 
			
		||||
  // partition of 日
 | 
			
		||||
  piece1 = unicodeData.slice(0, 20);
 | 
			
		||||
  piece2 = unicodeData.slice(20, unicodeData.length);
 | 
			
		||||
 | 
			
		||||
  s.write(piece1);
 | 
			
		||||
  s.write(piece2);
 | 
			
		||||
 | 
			
		||||
  s.end()
 | 
			
		||||
 | 
			
		||||
  it(caughtError).equal(false)
 | 
			
		||||
 | 
			
		||||
  it(rows).deepEqual(['テスト試験今日とても', 'よい天気で']);
 | 
			
		||||
 | 
			
		||||
  it(rows).deepEqual(x.split(','))
 | 
			
		||||
 | 
			
		||||
  test.done()
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										137
									
								
								express-server/node_modules/split/test/split.asynct.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								express-server/node_modules/split/test/split.asynct.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,137 @@
 | 
			
		||||
var es = require('event-stream')
 | 
			
		||||
  , it = require('it-is').style('colour')
 | 
			
		||||
  , d = require('ubelt')
 | 
			
		||||
  , split = require('..')
 | 
			
		||||
  , join = require('path').join
 | 
			
		||||
  , fs = require('fs')
 | 
			
		||||
  , Stream = require('stream').Stream
 | 
			
		||||
  , Readable = require('stream').Readable
 | 
			
		||||
  , spec = require('stream-spec')
 | 
			
		||||
  , through = require('through')
 | 
			
		||||
  , stringStream = require('string-to-stream')
 | 
			
		||||
 | 
			
		||||
exports ['split() works like String#split'] = function (test) {
 | 
			
		||||
  var readme = join(__filename)
 | 
			
		||||
    , expected = fs.readFileSync(readme, 'utf-8').split('\n')
 | 
			
		||||
    , cs = split()
 | 
			
		||||
    , actual = []
 | 
			
		||||
    , ended = false
 | 
			
		||||
    , x = spec(cs).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()
 | 
			
		||||
      })
 | 
			
		||||
  }
 | 
			
		||||
  a.writable = true
 | 
			
		||||
 | 
			
		||||
  fs.createReadStream(readme, {flags: 'r'}).pipe(cs)
 | 
			
		||||
  cs.pipe(a)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports ['split() takes mapper function'] = function (test) {
 | 
			
		||||
  var readme = join(__filename)
 | 
			
		||||
    , expected = fs.readFileSync(readme, 'utf-8').split('\n')
 | 
			
		||||
    , cs = split(function (line) { return line.toUpperCase() })
 | 
			
		||||
    , actual = []
 | 
			
		||||
    , ended = false
 | 
			
		||||
    , x = spec(cs).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]).equal(v.trim().toUpperCase())
 | 
			
		||||
      })
 | 
			
		||||
      //give the stream time to close
 | 
			
		||||
      process.nextTick(function () {
 | 
			
		||||
        test.done()
 | 
			
		||||
        x.validate()
 | 
			
		||||
      })
 | 
			
		||||
  }
 | 
			
		||||
  a.writable = true
 | 
			
		||||
 | 
			
		||||
  fs.createReadStream(readme, {flags: 'r'}).pipe(cs)
 | 
			
		||||
  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 (delimiter) {
 | 
			
		||||
  return function (arr, piece) {
 | 
			
		||||
    return arr.concat(piece.split(delimiter))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										51
									
								
								express-server/node_modules/split/test/try_catch.asynct.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								express-server/node_modules/split/test/try_catch.asynct.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
var it = require('it-is').style('colour')
 | 
			
		||||
  , split = require('..')
 | 
			
		||||
 | 
			
		||||
exports ['emit mapper exceptions as error events'] = function (test) {
 | 
			
		||||
  var s = split(JSON.parse)
 | 
			
		||||
    , caughtError = false
 | 
			
		||||
    , rows = []
 | 
			
		||||
 
 | 
			
		||||
  s.on('error', function (err) {
 | 
			
		||||
    caughtError = true
 | 
			
		||||
  })
 | 
			
		||||
 
 | 
			
		||||
  s.on('data', function (row) { rows.push(row) })
 | 
			
		||||
 | 
			
		||||
  s.write('{"a":1}\n{"')
 | 
			
		||||
  it(caughtError).equal(false)
 | 
			
		||||
  it(rows).deepEqual([ { a: 1 } ])
 | 
			
		||||
 | 
			
		||||
  s.write('b":2}\n{"c":}\n')
 | 
			
		||||
  it(caughtError).equal(true)
 | 
			
		||||
  it(rows).deepEqual([ { a: 1 }, { b: 2 } ])
 | 
			
		||||
 | 
			
		||||
  s.end()
 | 
			
		||||
  test.done()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports ['mapper error events on trailing chunks'] = function (test) {
 | 
			
		||||
  var s = split(JSON.parse)
 | 
			
		||||
    , caughtError = false
 | 
			
		||||
    , rows = []
 | 
			
		||||
 
 | 
			
		||||
  s.on('error', function (err) {
 | 
			
		||||
    caughtError = true
 | 
			
		||||
  })
 | 
			
		||||
 
 | 
			
		||||
  s.on('data', function (row) { rows.push(row) })
 | 
			
		||||
 | 
			
		||||
  s.write('{"a":1}\n{"')
 | 
			
		||||
  it(caughtError).equal(false)
 | 
			
		||||
  it(rows).deepEqual([ { a: 1 } ])
 | 
			
		||||
 | 
			
		||||
  s.write('b":2}\n{"c":}')
 | 
			
		||||
  it(caughtError).equal(false)
 | 
			
		||||
  it(rows).deepEqual([ { a: 1 }, { b: 2 } ])
 | 
			
		||||
 | 
			
		||||
  s.end()
 | 
			
		||||
  it(caughtError).equal(true)
 | 
			
		||||
  it(rows).deepEqual([ { a: 1 }, { b: 2 } ])
 | 
			
		||||
 | 
			
		||||
  test.done()
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user