Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
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.
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 malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.