Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-readable

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-readable - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

.eslintignore

6

CHANGELOG.md
# Changelog
## v3.1.0 2018-02-04
* New method `setEncoding`.
* `read` and `readAll` methods can return `string` if encoding is set.
* Support `import PromiseReadable from 'promise-readable'` syntax.
## v3.0.1 2018-02-04

@@ -4,0 +10,0 @@

6

lib/promise-readable.d.ts

@@ -10,5 +10,7 @@ /// <reference types="node" />

read (size?: number): Promise<Buffer | undefined>
readAll (): Promise<Buffer | undefined>
read (size?: number): Promise<Buffer | string | undefined>
readAll (): Promise<Buffer | string | undefined>
setEncoding (encoding: string): this
destroy (): void

@@ -15,0 +17,0 @@

@@ -187,2 +187,7 @@ 'use strict'

setEncoding (encoding) {
this.stream.setEncoding(encoding)
return this
}
destroy () {

@@ -189,0 +194,0 @@ this.stream.removeListener('error', this._errorHandler)

{
"name": "promise-readable",
"version": "3.0.1",
"version": "3.1.0",
"description": "Return promise for readable stream",

@@ -33,6 +33,9 @@ "main": "lib/promise-readable.js",

"tap": "^11.0.1",
"tap-given": "^0.6.0"
"tap-given": "^0.6.0",
"tslint": "^5.9.1",
"tslint-config-standard": "^7.0.0",
"typescript": "^2.7.1"
},
"scripts": {
"pretest": "standard --verbose | snazzy",
"pretest": "standard --verbose | snazzy && tsc --noEmit --pretty && tslint -t stylish -p .",
"test": "tap test/*.js",

@@ -39,0 +42,0 @@ "test:coverage": "npm test -- --coverage",

@@ -40,3 +40,3 @@ ## promise-readable

const fs = require('fs')
const { PromiseReadable } = require('promise-readable')
const PromiseReadable = require('promise-readable')

@@ -51,3 +51,3 @@ const stream = fs.createReadStream('/etc/hosts')

import * as fs from 'fs'
import { PromiseReadable } from 'promise-readable'
import PromiseReadable from 'promise-readable'

@@ -82,4 +82,2 @@ const stream = fs.createReadStream('/etc/hosts')

If stream2 API is available then additional argument `size` is accepted.
_Example:_

@@ -116,2 +114,24 @@

#### setEncoding
```js
promiseReadable = promiseReadable.setEncoding(encoding)
```
By default `read` and `readAll` methods returns `Buffer` objects.
This method sets the character encoding for data read from the stream. It might
be used if original stream does not provide `encoding` option.
The method returns this object.
_Example:_
```js
const asBuffer = await promiseReadable.read()
promiseReadable.setEncoding('utf8')
const asString = await promiseReadable.read()
```
#### once

@@ -118,0 +138,0 @@

{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",

@@ -4,0 +5,0 @@ "noImplicitReturns": true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc