nv-buf-quote
v1.0.6
Published
nv-buf-quote ======================= - read quoted-string AND \r\n FROM a bigfile
Downloads
1
Readme
nv-buf-quote
- read quoted-string AND \r\n FROM a bigfile
install
- npm install nv-buf-quote
usage
const {using_callback,creat_reader} = require("nv-buf-quote");
example
using callback
var x = using_callback;
var rs$ = fs.createReadStream("./package.json")
var arr = [];
var cb = (s)=> {
arr.push(s)
}
var getters = x(rs$,cb);
/*
> getters
{
state: [Function: state],
nqstr: [Function: nqstr],
qstr: [Function: qstr],
q: [Function: q],
qlit: [Function: qlit],
lefted: [Function: lefted]
}
>
*/
/*
console.log(arr);
[
'\n',
' ',
'"name"',
': ',
'"nv-buf-quote"',
',',
'\n',
' ',
'"version"',
': ',
'"1.0.0"',
',',
'\n',
' ',
'"main"',
': ',
'"index.js"',
',',
'\n',
' ',
'"scripts"',
': {',
'\n',
' ',
'"test"',
': ',
'"echo \\"Error: no test specified\\" && exit 1"',
'',
'\n',
' },',
'\n',
' ',
'"author"',
': ',
'""',
',',
'\n',
' ',
'"license"',
': ',
'"ISC"',
',',
'\n',
' ',
'"description"',
': ',
'""',
',',
'\n',
' ',
'"dependencies"',
': {',
'\n',
' ',
'"nv-buf-utf8-boundary"',
': ',
'"^1.0.1"',
'',
'\n',
' }',
'\n',
'}',
'\n',
Continuation {
cond: true,
reason: null,
___end___: true,
state: 0,
nqstr: '',
qstr: '',
q: -1,
qlit: '',
lefted: []
}
]
*/
async creat_reader
var rs$ = fs.createReadStream("./package.json")
var x = creat_reader;
var g = x(rs$)
var queue = (await g.next()).value
(await g.next()).value
(await g.next()).value
(await g.next()).value
big file
# ls -l ./TEST/
total 1597412
-rw-r--r-- 1 root root 1635738404 Jun 18 17:14 big.txt
-rw-r--r-- 1 root root 756 Jun 18 17:12 make-big-random-text.js
callback
const {using_callback,creat_reader} =require("./index");
const {creat_one,rtrn} = require("nd-reflect-promise");
var rs$ = fs.createReadStream("./TEST/big.txt")
var x = using_callback
var si = new Date;
var curr;
var ei ;
var p = creat_one();
var cb = (s)=>{
curr = new Date
if(s.___end___) {
ei = new Date
console.log(ei - si)
rtrn(p)
}
}
using_callback(rs$,cb);
await p
/*
> 17652 17 seconds to parse 1.6G txt
*/
async reader
var rs$ = fs.createReadStream("./TEST/big.txt")
var x = creat_reader;
var g = x(rs$)
var queue = (await g.next()).value
var R;
var p = (async ()=>{
var si = new Date;
for await(let e of g) {R=e}
var ei = new Date;
console.log(ei-si)
return(ei-si)
})()
/*
> 15635
*/
METHODS
APIS
LICENSE
- ISC