2-thenable

WebJar for 2-thenable

Лицензия

Лицензия

ISC
Группа

Группа

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

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

2-thenable
Последняя версия

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

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

2-thenable
WebJar for 2-thenable
Ссылка на сайт

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

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

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

https://github.com/medikoo/2-thenable

Скачать 2-thenable

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

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

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.webjars.npm : d jar [1,2)
org.webjars.npm : es5-ext jar [0.10.47,0.11)

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

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

*nix build status Windows build status Tests coverage Transpilation status npm version

2-thenable

Convert object into a thenable

Useful when we want to imply an asynchronous representation onto some non-promise object.

Having that target object can be combined into promise chains or async/await syntax. One use case would be turning a stream instance so it's also a promise.

Installation

npm install 2-thenable

How it works

Utility takes target and promise arguments. target is object to be extended with then, catch and finally methods. While promise is expected to be a native promise instance that reflects resolution which should be mapped onto target

Usage

Example of converting stream to thenable

const toThenable = require("2-thenable");

// Example of converting a simple utf8 string stream to thenable
toThenable(stream, new Promise((resolve, reject) => {
	let result = '';
	stream.on('error', reject);
	stream.on('data', data => (result += data));
	stream.on('end', () => resolve(result));
});

stream.then(result => {
	console.log("Cumulated string data", result);
});

Tests

npm test

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

Версия
1.0.0