
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
random-line-access
Advanced tools
Provides random access to keyed lines of arbitrarily sized files.
If you have a file larger than memory that you want to retrieve rows from at random, and your file happens to be structured such that the first word of each line can be regarded as a key for the entire line, well, then this is what you've been looking for.
example1,1,2,3,4
example2,hamburger,rango,,,martians
somemore,ozone,zone,zoneout
"wow complex",margarine,bananas,,,robot
const randomLineAccess = require('random-line-access')
let rla = randomLineAccess('huge.csv', {sep: ','})
rla.ls(function(err, ls) {
console.log(ls) // ['example1', 'example2', 'somemore', '"wow']
})
rla.get('example2', function(err, data) {
console.log(data) // ['hamburger', 'rango', 'martians']
})
let rla = randomLineAccess('huge.csv', {sep: ',', omitEmpty: false})
rla.get('example2', function(err, data) {
console.log(data) // ['hamburger', 'rango', '', '', '', 'martians']
})
let rla = randomLineAccess('huge.csv')
rla.get('example1', function(err, data) {
console.log(data) // '1,2,3,4'
})
let rla = randomLineAccess('huge.csv', {sep: ',', quotes: true})
rla.ls(function(err, ls) {
console.log(ls) // ['example1', 'example2', 'somemore', 'wow complex']
})
rla.get('wow complex', function(err, data) {
console.log(data) // ['margarine', 'bananas', 'robot']
})
rla.set('wow complex', ['molasses'], function(err, data) {
console.log(data) // ['molasses']
})
rla.close()
omitEmpty Expects a boolean, defaults to true. Removes empty values.quotes Expects a boolean, defaults to false. Accepts quotes in the key value (IS IGNORED IN SEPARATED VALUES)sep Expects a string. When provided, returns values seperated by the separator, and inserts arrays joined by seperator.get(key, callback)
Takes a key and returns the value retrieved to the callback.
set(key, buffer, callback) Careful: the set operator has write permission, and no undo
Takes a key, and either a buffer or a string. If the resulting buffer from the string or buffer is
longer than the line in the document then this will raise an error. Dynamic reassignment of sizes
ls(callback)
Returns all keys found in the document. Remember, keys are assumed to be the first string in the beginning of each line in the document.
close(callback)
Closes the file.
$ npm install random-line-access
FAQs
Random access line
The npm package random-line-access receives a total of 1 weekly downloads. As such, random-line-access popularity was classified as not popular.
We found that random-line-access 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
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.