Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.markdown 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Split (matcher)
  2. [![build status](https://secure.travis-ci.org/dominictarr/split.png)](http://travis-ci.org/dominictarr/split)
  3. Break up a stream and reassemble it so that each line is a chunk. matcher may be a `String`, or a `RegExp`
  4. Example, read every line in a file ...
  5. ``` js
  6. fs.createReadStream(file)
  7. .pipe(split())
  8. .on('data', function (line) {
  9. //each chunk now is a separate line!
  10. })
  11. ```
  12. `split` takes the same arguments as `string.split` except it defaults to '/\r?\n/' instead of ',', and the optional `limit` parameter is ignored.
  13. [String#split](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/split)
  14. `split` takes an optional options object on its third argument.
  15. ``` js
  16. split(matcher, mapper, options)
  17. ```
  18. Valid options:
  19. * maxLength - The maximum buffer length without seeing a newline or `matcher`,
  20. if a single line exceeds this, the split stream will emit an error.
  21. ``` js
  22. split(JSON.parse, null, { maxLength: 2})
  23. ```
  24. * trailing - By default the last buffer not delimited by a newline or `matcher` will be emitted. To prevent this set `options.trailing` to `false`.
  25. ``` js
  26. split(JSON.parse, null, { trailing: false })
  27. ```
  28. ## keep matched splitter
  29. As with `String#split`, if you split by a regular expression with a matching group,
  30. the matches will be retained in the collection.
  31. ```
  32. stdin
  33. .pipe(split(/(\r?\n)/))
  34. ... //lines + separators.
  35. ```
  36. # NDJ - Newline Delimited Json
  37. `split` accepts a function which transforms each line.
  38. ``` js
  39. fs.createReadStream(file)
  40. .pipe(split(JSON.parse))
  41. .on('data', function (obj) {
  42. //each chunk now is a a js object
  43. })
  44. .on('error', function (err) {
  45. //syntax errors will land here
  46. //note, this ends the stream.
  47. })
  48. ```
  49. # License
  50. MIT