match-stream

WebJar for match-stream

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

match-stream
Последняя версия

Последняя версия

0.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

match-stream
WebJar for match-stream
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/EvanOxfeld/match-stream

Скачать match-stream

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/match-stream/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>match-stream</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/match-stream/
implementation 'org.webjars.npm:match-stream:0.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/match-stream/
implementation ("org.webjars.npm:match-stream:0.0.2")
'org.webjars.npm:match-stream:jar:0.0.2'
<dependency org="org.webjars.npm" name="match-stream" rev="0.0.2">
  <artifact name="match-stream" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='match-stream', version='0.0.2')
)
libraryDependencies += "org.webjars.npm" % "match-stream" % "0.0.2"
[org.webjars.npm/match-stream "0.0.2"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.webjars.npm » buffers jar [0.1.1,0.2)
org.webjars.npm : readable-stream jar [1.0.0,1.1)

Модули Проекта

Данный проект не имеет модулей.

match-stream Build Status

Supply a function to handle pattern matches within a NodeJS stream.

Installation

$ npm install match-stream

Quick Examples

End stream on match

var MatchStream = require('match-stream');
var streamBuffers = require("stream-buffers");

var ms = new MatchStream({ pattern: 'World'}, function (buf, matched, extra) {
  if (!matched) {
    return this.push(buf);
  }
  this.push(buf);
  return this.push(null); //signal end of data
});

var sourceStream = new streamBuffers.ReadableStreamBuffer();
sourceStream.put("Hello World");
var writableStream = new streamBuffers.WritableStreamBuffer();

sourceStream
  .pipe(ms)
  .pipe(writableStream)
  .once('close', function () {
    var str = writableStream.getContentsAsString('utf8');
    console.log('Piped data before pattern occurs:', "'" + str + "'");
    sourceStream.destroy();
  });

//Output
//Piped data before pattern occurs: 'Hello '

Split stream

var MatchStream = require('match-stream');
var fs = require('fs');

var line = "";
var loremLines = [];
var ms = new MatchStream({ pattern: '.', consume: true}, function (buf, matched, extra) {
  line += buf.toString();
  if (matched) {
    loremLines.push(line.trim());
    line = "";
  }
});

fs.createReadStream('lorem.txt')
  .pipe(ms)
  .once('finish', function() {
    console.log(loremLines);
  });

License

MIT

Acknowledgements

Special thanks to @wanderview for assisting with the API.

Версии библиотеки

Версия
0.0.2