Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
from2-array
Advanced tools
The from2-array npm package is a utility that allows you to create a readable stream from an array of values. This can be particularly useful for testing, prototyping, or when you need to convert an array into a stream for further processing.
Create a readable stream from an array
This feature allows you to create a readable stream from an array of values. The stream emits each value in the array as a chunk of data.
const from2Array = require('from2-array');
const stream = from2Array(['a', 'b', 'c']);
stream.on('data', (chunk) => {
console.log(chunk.toString());
});
Create a readable stream from an array with a custom read function
This feature allows you to create a readable stream from an array with a custom read function. The custom read function can be used to control how data is read from the array.
const from2Array = require('from2-array');
const stream = from2Array.obj(['a', 'b', 'c'], (size, next) => {
next(null, this.values.shift() || null);
});
stream.on('data', (chunk) => {
console.log(chunk);
});
The from2 package is a more general version of from2-array that allows you to create a readable stream from any source, not just arrays. It provides a flexible API for creating streams from various data sources.
The readable-stream package is a core Node.js module that provides a standard interface for creating readable streams. It is more comprehensive and versatile compared to from2-array, as it supports a wide range of stream operations and transformations.
The stream-array package is similar to from2-array in that it allows you to create a readable stream from an array. However, it is less flexible and does not support custom read functions like from2-array does.
Create a from2 stream based on an array of source values
Useful when you want to create a Readable stream with some values you already have in an array
var from = require('from2-array')
var through = require('through2')
from.obj([{
name:'a'
},{
name:'b'
},{
name:'c'
}]).pipe(through.obj(function(chunk, enc, cb){
console.log('found: ' + chunk.name)
cb()
}))
MIT
FAQs
Create a from2 stream based on an array of source values
We found that from2-array 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.