
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
are-streams-same
Advanced tools
Check if the contents of two Node.js streams are the same.
This module does not need any dependencies. If you want to 'require' 'are-streams-same', then you will need rollup
/
npm i are-streams-same
There is a default function that takes in two readable streams and returns a promise. See the index.d.ts
file for typescript definitions.
import { createReadStream } from 'fs';
import areStreamsSame from 'are-streams-same';
//a.txt: Hello
const stream1 = createReadStream('a.txt');
//b.txt: Hello World
const stream2 = createReadStream('b.txt');
areStreamsSame(stream1, stream2)
.then(result => {
console.log(result);
/*
{
same: false,
reason: 'The length of a stream exceeded the length of the other stream which was finished.'
};
*/
})
import { createReadStream } from 'fs';
import { createHash } from 'crypto';
import areStreamsSame from 'are-streams-same';
//The old hash
const stream1 = createReadStream('hash.dat');
//The new hash
const stream2 = createReadStream('input.txt')
.pipe(createHash('sha256'));
areStreamsSame(stream1, stream2)
.then(({ same }) => {
if(same){
console.log("File hasn't changed");
}
else{
console.log("File is different");
}
})
rollup
for building if you are using commonjs.index.js
is the only file with logic. index.d.ts
is a small file for typescript definitions. There is also a file called build/cjs.cjs
which is to transpile index.js
into commonjs, to support commonjs.index.d.ts
.This module is made with ESModules. ESModules are able to use other ESModules and CommonJs modules, but CommonJS modules aren't able to use ESModules. If you are using, CommonJS (require('are-streams-same')
), or want to support CommonJS, then you can build a CommonJS file by using the build/cjs.cjs
file. It is a file that exports an async function which uses rollup
to generate the dist/cjs/index.cjs
file. The function takes rollup
as its argument. For example, you might have a setup like this:
const rollup = require('rollup');
const build = require('are-streams-same/build/cjs.cjs');
build(rollup)
.then(() => {
console.log("done building");
});
{
"scripts": {
"build": "node build.js",
"postinstall": "node build.js"
}
}
Then you can do
npm run build
to generated dist/cjs/index.cjs
. Then you can use this package normally by doing:
require('are-streams-same');
FAQs
Check if the contents of two Node.js streams are the same.
The npm package are-streams-same receives a total of 0 weekly downloads. As such, are-streams-same popularity was classified as not popular.
We found that are-streams-same demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.