New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stream-promise

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-promise - npm Package Compare versions

Comparing version

to
3.2.0

.prettierrc.js

34

CHANGELOG.md

@@ -5,41 +5,41 @@ # Change Log

# [3.2.0](https://github.com/medikoo/stream-promise/compare/v3.1.0...v3.2.0) (2019-03-15)
### Features
- `noCollect` option ([8adbdf8](https://github.com/medikoo/stream-promise/commit/8adbdf8))
<a name="3.1.0"></a>
# [3.1.0](https://github.com/medikoo/stream-promise/compare/v3.0.0...v3.1.0) (2019-01-17)
### Bug Fixes
* writable streams should resolve with udefined ([ab21212](https://github.com/medikoo/stream-promise/commit/ab21212))
- writable streams should resolve with udefined ([ab21212](https://github.com/medikoo/stream-promise/commit/ab21212))
### Features
* expose emitted data at emittedData property ([b35d101](https://github.com/medikoo/stream-promise/commit/b35d101))
- expose emitted data at emittedData property ([b35d101](https://github.com/medikoo/stream-promise/commit/b35d101))
<a name="3.0.0"></a>
<a name="3.0.0"></a>
# [3.0.0](https://github.com/medikoo/stream-promise/compare/v1.0.0...v3.0.0) (2019-01-17)
### Chores
* publish as steam-promise ([feff7a5](https://github.com/medikoo/stream-promise/commit/feff7a5))
- publish as steam-promise ([feff7a5](https://github.com/medikoo/stream-promise/commit/feff7a5))
### Features
* stream to promise approach ([8669fab](https://github.com/medikoo/stream-promise/commit/8669fab))
- stream to promise approach ([8669fab](https://github.com/medikoo/stream-promise/commit/8669fab))
### BREAKING CHANGES
* Remove non that useful StreamPromise construtor with utility
that converts initialized stream to promise
* We're skipping v1 to avoid semver confusion with
previously published version by other author
- Remove non that useful StreamPromise construtor with utility
that converts initialized stream to promise
- We're skipping v1 to avoid semver confusion with
previously published version by other author
<a name="1.0.0"></a>
<a name="1.0.0"></a>
# 1.0.0 (2019-01-14)
{
"name": "stream-promise",
"version": "3.1.0",
"description": "Promise that shares Node.js Stream interface",
"author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",
"keywords": [
"promise",
"stream",
"emitter",
"event-emitter"
],
"repository": "medikoo/stream-promise",
"dependencies": {
"2-thenable": "1",
"es5-ext": "^0.10.47",
"is-stream": "^1.1"
},
"devDependencies": {
"chai": "^4.2",
"eslint": "^5.12",
"eslint-config-medikoo": "^2",
"mocha": "^5.2",
"nyc": "^13.1"
},
"eslintConfig": {
"extends": "medikoo",
"root": true,
"env": {
"node": true
},
"overrides": [
{
"files": "test/**/*.js",
"env": {
"mocha": true
}
}
]
},
"scripts": {
"coverage": "nyc --reporter=lcov --reporter=html --reporter=text-summary npm test",
"check-coverage": "npm run coverage && nyc check-coverage --statements 80 --function 80 --branches 50 --lines 80",
"lint": "eslint --ignore-path=.gitignore .",
"test": "mocha"
},
"license": "ISC"
"name": "stream-promise",
"version": "3.2.0",
"description": "Promise that shares Node.js Stream interface",
"author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",
"keywords": [
"promise",
"stream",
"emitter",
"event-emitter"
],
"repository": "medikoo/stream-promise",
"dependencies": {
"2-thenable": "^1.0.0",
"es5-ext": "^0.10.49",
"is-stream": "^1.1.0"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.15.1",
"eslint-config-medikoo": "^2.1.1",
"git-list-updated": "^1.1.2",
"husky": "^1.3.1",
"lint-staged": "^8.1.5",
"mocha": "^6.0.2",
"nyc": "^13.3.0",
"prettier-elastic": "^1.16.4"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"eslint"
],
"*.{css,html,js,json,md,yaml,yml}": [
"prettier -c"
]
},
"eslintConfig": {
"extends": "medikoo",
"root": true,
"env": {
"node": true
},
"overrides": [
{
"files": "test/**/*.js",
"env": {
"mocha": true
}
}
]
},
"scripts": {
"coverage": "nyc --reporter=lcov --reporter=html --reporter=text-summary npm test",
"check-coverage": "npm run coverage && nyc check-coverage --statements 80 --function 80 --branches 50 --lines 80",
"lint": "eslint --ignore-path=.gitignore .",
"lint-updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'",
"prettier-check-updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
"prettify": "prettier --write --ignore-path .gitignore '**/*.{css,html,js,json,md,yaml,yml}'",
"test": "mocha"
},
"license": "ISC"
}

@@ -32,11 +32,7 @@ [![*nix build status][nix-build-image]][nix-build-url]

someReadableStream.then(result => {
console.log("Concatenated stream output", result);
});
someReadableStream.then(result => { console.log("Concatenated stream output", result); });
streamPromise(someWritabletream);
someReadableStream.then(result => {
console.log("Cumulated stream output", result);
});
someReadableStream.then(result => { console.log("Cumulated stream output", result); });
```

@@ -55,7 +51,13 @@

someReadableStreamPromise.then(result => {
console.log("Concatenated stream output", result);
});
someReadableStreamPromise.then(result => { console.log("Concatenated stream output", result); });
```
## Supported options
### noCollect `boolean` (default: `false`)
Applicable to _readable_ streams. Set to true, if it's not intended to gather stream result and resolve with it.
Then the only purpose of promise would be to indicate a moment when data stream is finalized
### Tests

@@ -62,0 +64,0 @@

"use strict";
const toShortString = require("es5-ext/to-short-string-representation")
const isObject = require("es5-ext/object/is-object")
, toShortString = require("es5-ext/to-short-string-representation")
, isStream = require("is-stream");
module.exports = stream => {
module.exports = (stream, options = {}) => {
if (!isObject(options)) options = {};
if (!isStream(stream)) throw new TypeError(`${ toShortString(stream) } is not a stream`);

@@ -18,3 +20,5 @@ if (!isStream.readable(stream) && !isStream.writable(stream)) {

if (isStream.readable(stream)) {
if (stream._readableState.objectMode) {
if (options.noCollect) {
result = undefined;
} else if (stream._readableState.objectMode) {
result = [];

@@ -46,4 +50,4 @@ stream.on("data", data => result.push(data));

});
if (isStream.readable) promise.emittedData = result;
if (isStream.readable && !options.noCollect) promise.emittedData = result;
return promise;
};

Sorry, the diff of this file is not supported yet