clone-response

WebJar for clone-response

Лицензия

Лицензия

MIT
Группа

Группа

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

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

clone-response
Последняя версия

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

1.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

clone-response
WebJar for clone-response
Ссылка на сайт

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

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

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

https://github.com/lukechilds/clone-response

Скачать clone-response

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

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.webjars.npm : mimic-response jar [1.0.0,2)

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

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

clone-response

Clone a Node.js HTTP response stream

Build Status Coverage Status npm npm

Returns a new stream and copies over all properties and methods from the original response giving you a complete duplicate.

This is useful in situations where you need to consume the response stream but also want to pass an unconsumed stream somewhere else to be consumed later.

Install

npm install --save clone-response

Usage

const http = require('http');
const cloneResponse = require('clone-response');

http.get('http://example.com', response => {
  const clonedResponse = cloneResponse(response);
  response.pipe(process.stdout);

  setImmediate(() => {
    // The response stream has already been consumed by the time this executes,
    // however the cloned response stream is still available.
    doSomethingWithResponse(clonedResponse);
  });
});

Please bear in mind that the process of cloning a stream consumes it. However, you can consume a stream multiple times in the same tick, therefore allowing you to create multiple clones. e.g:

const clone1 = cloneResponse(response);
const clone2 = cloneResponse(response);
// response can still be consumed in this tick but cannot be consumed if passed
// into any async callbacks. clone1 and clone2 can be passed around and be
// consumed in the future.

API

cloneResponse(response)

Returns a clone of the passed in response.

response

Type: stream

A Node.js HTTP response stream to clone.

License

MIT © Luke Childs

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

Версия
1.0.2