-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
36 lines (36 loc) · 4.55 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
"name": "eachline",
"version": "2.3.3",
"description": "Streams2 line reader",
"keywords": [
"streams2",
"linereader",
"async",
"asynchronous",
"pipe",
"transform"
],
"homepage": "http://github.com/williamwicks/node-eachline",
"repository": {
"type": "git",
"url": "git://github.com/williamwicks/node-eachline.git"
},
"author": {
"name": "William Wicks",
"email": "wjwicks@gmail.com"
},
"main": "./eachline.js",
"dependencies": {
"type-of": "~2"
},
"engines": {
"node": ">=0.10.0"
},
"readme": "#eachline\n\nStreams2 line reader / stream transformer.\n\nFirst let me say: I did **NOT** want to write yet another line reader! \nI couldn't find one that is working with node's new `Streams2` objects.\n\nThe [byline](https://github.com/jahewson/node-byline) module has taken a first stab at it, \nbut it isn't working. (as of [32bf791e38](https://github.com/jahewson/node-byline/commit/32bf791e387a46c720b604d8d5807eeb8f668ddf))\n\n**So here we are...**\n```javascript\nvar fs = require('fs');\nvar eachline = require('eachline');\nvar stream = fs.createReadStream(__dirname+'/.gitignore');\n\neachline(stream, function(line){\n console.log(line);\n});\n```\n\nHowever, if you're just looking to open a file:\n```javascript\nvar eachline = require('eachline');\neachline.in(__dirname+'/.gitignore', function(line){\n console.log(line);\n});\n```\n\n...or if you need a simple http GET:\n```javascript\nvar eachline = require('eachline');\nvar url = 'https://raw.github.com/williamwicks/node-eachline/master/.gitignore';\neachline.in(url, function(line){\n console.log(line);\n});\n```\n\n##Transforming Streams\n[eachline](https://github.com/williamwicks/node-eachline) uses `Streams2`'s transformation \nfeature allowing you to throw [eachline](https://github.com/williamwicks/node-eachline) between `.pipe()`s\nto modify output as needed.\n\n```javascript\nvar fs = require('fs');\nvar eachline = require('eachline');\nvar file = fs.createReadStream(__dirname+'/.gitignore');\n\nvar transformer = eachline(function(data){\n return data.substr(0, 2)+'\\n';\n});\n\nfile.pipe(transformer).pipe(process.stdout);\n```\n\n##API\n###eachline([encoding,] callback)\nUse with `pipe()` optionally specifying the encoding.\n\n###eachline(ReadableStream,[ encoding,] callback)\nGot that stream ready? Pass it in, get them lines. Easy-peasy.\n\n###eachline.in(url, callback)<br>\neachline.in(filepath, callback)\nJust a helper function to make these simple tasks cleaner.\n\nIt returns the `Transform` stream so you can listen to the events.\n```javascript\nvar linecount = 0;\nvar eachline = require('eachline');\neachline.in(__dirname+'/.gitignore', function(data){\n\tlinecount++;\n})\n.on('finish', function(){\n\tconsole.log(linecount + \" lines found\");\n});\n```\n\n**callback(data, lineno[ ,next])**<BR>\nThe `callback` arguments above will be called for every line found in the `ReadableStream`.\n\nIt will be passed the `data` and `lineno` arguments. You can optionally defined a\n3rd argument to get asynchronous flow. `eachline` examines `callback.length` to detirmine\nif asynchronous flow should be used. If found, you must call `next()` to continue reading.\n\nFor Stream transformations, any value `return`'d will be written to the next `pipe()` in the chain.\n\n\nLicense\n=======\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 William Wicks\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/williamwicks/node-eachline/issues"
},
"_id": "eachline@2.3.3",
"_from": "eachline@2.3.3"
}