🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

rw

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rw - npm Package Compare versions

Comparing version

to
0.0.2

14

lib/rw/write.js

@@ -9,10 +9,10 @@ var fs = require("fs");

try {
// ignore broken pipe, e.g., | head -n 1000
process.stdout.once("error", function(error) {
if (error.code !== "EPIPE") process.stdout.emit("error", error);
});
// ignore broken pipe, e.g., | head -n 1000
process.stdout.write(data, function(error) {
callback(error.code === "EPIPE" ? null : error);
if (error.code === "EPIPE") { // ignore broken pipe, e.g., | head -n 1000
error = null;
process.stdout.once("error", function(error) {
if (error.code !== "EPIPE") process.stdout.emit("error", error);
});
}
callback(error);
});

@@ -19,0 +19,0 @@ } catch (error) {

{
"name": "rw",
"version": "0.0.1",
"version": "0.0.2",
"description": "Wrappers of fs.{read,write}File that work for /dev/std{in,out}.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -38,6 +38,20 @@ # stdin & stdout, the right way

But that’s a pain, since now your code has two different code paths for reading inputs, depending on whether you’re reading a real file or stdin.
But that’s a pain, since now your code has two different code paths for reading inputs, depending on whether you’re reading a real file or stdin. And the code gets even more complex if you want to read that file synchronously.
And the code gets even more complex if you want to read that file synchronously.
You could also try a different pattern for writing to stdout:
```js
process.stdout.write(contents);
```
But if you try to pipe your output to `head`, you’ll get this error:
```
Error: write EPIPE
at errnoException (net.js:904:11)
at Object.afterWrite (net.js:720:19)
```
Huh.
## rw

@@ -59,2 +73,2 @@

Also, **rw** automatically squashes EPIPE errors, so you can pipe the output of your program to `head` and you won’t get a spurious stack trace.
And **rw** automatically squashes EPIPE errors, so you can pipe the output of your program to `head` and you won’t get a spurious stack trace.