{"dist":{"shasum":"d63c9cd54a9645552e3fed9d9ea2d7fce22fd5a7","tarball":"https://registry.npmjs.org/buffered-reader/-/buffered-reader-1.0.1.tgz","integrity":"sha512-4TNbMdUqsoE/AjPuuoGp5/kxce9gMmkbrBXOP5J/DHYasUyqwHtmWWPpmi5Om/Jx065xr8PRfVvz3km27wHtNw==","signatures":[{"sig":"MEQCIC/UblWAkwsapw3ScVNd67enWVwKtUm/nbgE9P5KMtDKAiATChImVH8JXM2dNzNRYc0dZjCcjyqFmmlXZqde+YNqnw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"buffered-reader","name":"buffered-reader","author":{"name":"Gabriel Llamas"},"readme":"<a name=\"start\"></a>\r\n\r\nNode BufferedReader\r\n===================\r\n\r\n_Node.js project_\r\n\r\n#### Binary and event-based data buffered readers ####\r\n\r\n[Show me!](#showme) | [Availability](#availability) | [Compatibility](#compatibility) | [Documentation](#documentation)\r\n\r\nVersion: 1.0.1\r\n\r\nWhen you need to read a file you typically read a chunk of bytes called \"buffer\" to avoid multiple calls to the underlying I/O layer, so instead of reading directly from the disk, you read from the previous filled buffer. Doing this you win performance.\r\n\r\nThis library allows you to read files without worry about the buffers. There are two ways to read the files. The first can only read binary data and has a pointer to move along the file (seek, skip, read). The second performs a read from the beginning to the end of the file and emits different events (byte, character, line, buffer...).\r\n\r\n<a name=\"showme\"></a>\r\n#### Show me! [↑](#start) ####\r\n\r\n```javascript\r\nvar reader = require (\"buffered-reader\");\r\nvar BinaryReader = reader.BinaryReader;\r\nvar DataReader = reader.DataReader;\r\n\r\nvar close = function (binaryReader, error){\r\n\tif (error) console.log (error);\r\n\t\r\n\tbinaryReader.close (function (error){\r\n\t\tif (error) console.log (error);\r\n\t});\r\n};\r\n\r\nvar file = \"file\";\r\nvar offset;\r\n\r\nnew DataReader (file, { encoding: \"utf8\" })\r\n\t\t.on (\"error\", function (error){\r\n\t\t\tconsole.log (error);\r\n\t\t})\r\n\t\t.on (\"line\", function (line, nextByteOffset){\r\n\t\t\tif (line === \"Phasellus ultrices ligula sed odio ultricies egestas.\"){\r\n\t\t\t\toffset = nextByteOffset;\r\n\t\t\t\tthis.interrupt ();\r\n\t\t\t}\r\n\t\t})\r\n\t\t.on (\"end\", function (){\r\n\t\t\tnew BinaryReader (file)\r\n\t\t\t\t\t.seek (offset, function (error){\r\n\t\t\t\t\t\tif (error) return close (this, error);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthis.read (9, function (error, bytes, bytesRead){\r\n\t\t\t\t\t\t\tif (error) return close (this, error);\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tconsole.log (bytes.toString ()); //Prints: Curabitur\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tclose (this);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t});\r\n\t\t})\r\n\t\t.read ();\r\n```\r\n\r\nfile:\r\n\r\n```text\r\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\r\nMorbi convallis nibh massa, eu varius felis.\r\n\r\nPhasellus ultrices ligula sed odio ultricies egestas.\r\nCurabitur pretium magna in diam accumsan dignissim.\r\nPhasellus et tortor eu orci suscipit vehicula.\r\nPhasellus pulvinar mauris in purus consequat vel congue orci hendrerit.\r\nPellentesque eget arcu magna, suscipit imperdiet eros.\r\n```\r\n\r\n***\r\n\r\n<a name=\"availability\"></a>\r\n#### Availability [↑](#start) ####\r\n\r\nVia npm:\r\n\r\n```\r\nnpm install buffered-reader\r\n```\r\n\r\n***\r\n\r\n<a name=\"compatibility\"></a>\r\n#### Compatibility [↑](#start) ####\r\n\r\n✔ Node *\r\n\r\n***\r\n\r\n<a name=\"documentation\"></a>\r\n#### Documentation [↑](#start) ####\r\n \r\n[Reference](https://github.com/Gagle/Node-BufferedReader/wiki/Reference)  \r\n[Examples](https://github.com/Gagle/Node-BufferedReader/tree/master/examples)  \r\n[Change Log](https://github.com/Gagle/Node-BufferedReader/wiki/Change-Log)  \r\n[MIT License](https://github.com/Gagle/Node-BufferedReader/blob/master/LICENSE)","engines":{"node":"*"},"_npmUser":{"name":"Gagle","email":"gaglekas@gmail.com"},"keywords":["buffer","reader","line","read line","file","read file","read text file","read binary file","binary"],"licenses":[{"url":"http://www.opensource.org/licenses/mit-license.html","type":"MIT"}],"repository":{"url":"git://github.com/Gagle/Node-BufferedReader.git","type":"git"},"_npmVersion":"1.1.62","description":"Binary and event-based data buffered readers.","maintainers":[{"name":"Gagle","email":"gaglekas@gmail.com"}],"dependencies":{"errno-codes":"*"},"_id":"buffered-reader@1.0.1","version":"1.0.1"}