Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
browser-line-reader
Advanced tools
An asynchronous line by line file reader for the browser.
This is a project I have been working on since I have found the lack of asynchronous, promise aware, typescript based file reader solutions lacking when it comes to the browser.
This module is designed to read a File object, using the standard FileReader, one line at a time. In order to achieve this, the file is actually subject to multiple reads, in "chunks", which can contain any number of lines.
What this means is that there is no need for the entire file to be stored in browser memory, and lines can be processed and then discarded. I find that this is especially useful when reading in large files spanning many hundreds of megabytes.
npm install browser-line-reader --save
Currently, there is only one function accessible, readLines
,
which will read all the lines of a file, one by one. The usage
can be described by the below code example:
import LineReader from 'browser-line-reader';
const myFile: File = new File(['My name is...'], 'SlimShady');
const lineReader: LineReader = new LineReader(myFile);
lineReader.readLines((line: string) => {
// Efficiently store this line in a good data structure
console.log(line);
}).then((numLinesRead: number) => {
console.log(`Finished and read ${numLinesRead} lines`);
}).catch((err) => {
console.log(err);
});
File
,
which is the File object to read.readLines
function accepts a callback with
one parameter of type string
, which is the line just read.readLines
function returns a promise with return type
Promise<number|string>
, where on success, the total number of
lines read is returned, and on failure, an error message.There are a number of items I would still like to implement. This list is growing and feel free to send me suggestions if you find this tool useful.
FAQs
A line by line async file reader for the browser
The npm package browser-line-reader receives a total of 46 weekly downloads. As such, browser-line-reader popularity was classified as not popular.
We found that browser-line-reader 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.