08-27-周三_17-09-29
This commit is contained in:
4
node_modules/stringstream/.travis.yml
generated
vendored
Normal file
4
node_modules/stringstream/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.4
|
||||
- 0.6
|
22
node_modules/stringstream/LICENSE.txt
generated
vendored
Normal file
22
node_modules/stringstream/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012 Michael Hart (michael.hart.au@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
38
node_modules/stringstream/README.md
generated
vendored
Normal file
38
node_modules/stringstream/README.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# Decode streams into strings The Right Way(tm)
|
||||
|
||||
```javascript
|
||||
var fs = require('fs')
|
||||
var zlib = require('zlib')
|
||||
var strs = require('stringstream')
|
||||
|
||||
var utf8Stream = fs.createReadStream('massiveLogFile.gz')
|
||||
.pipe(zlib.createGunzip())
|
||||
.pipe(strs('utf8'))
|
||||
```
|
||||
|
||||
No need to deal with `setEncoding()` weirdness, just compose streams
|
||||
like they were supposed to be!
|
||||
|
||||
Handles input and output encoding:
|
||||
|
||||
```javascript
|
||||
// Stream from utf8 to hex to base64... Why not, ay.
|
||||
var hex64Stream = fs.createReadStream('myFile')
|
||||
.pipe(strs('utf8', 'hex'))
|
||||
.pipe(strs('hex', 'base64'))
|
||||
```
|
||||
|
||||
Also deals with `base64` output correctly by aligning each emitted data
|
||||
chunk so that there are no dangling `=` characters:
|
||||
|
||||
```javascript
|
||||
var stream = fs.createReadStream('myFile').pipe(strs('base64'))
|
||||
|
||||
var base64Str = ''
|
||||
|
||||
stream.on('data', function(data) { base64Str += data })
|
||||
stream.on('end', function() {
|
||||
console.log('My base64 encoded file is: ' + base64Str) // Wouldn't work with setEncoding()
|
||||
console.log('Original file is: ' + new Buffer(base64Str, 'base64'))
|
||||
})
|
||||
```
|
27
node_modules/stringstream/example.js
generated
vendored
Normal file
27
node_modules/stringstream/example.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var fs = require('fs')
|
||||
var zlib = require('zlib')
|
||||
var strs = require('stringstream')
|
||||
|
||||
var utf8Stream = fs.createReadStream('massiveLogFile.gz')
|
||||
.pipe(zlib.createGunzip())
|
||||
.pipe(strs('utf8'))
|
||||
|
||||
utf8Stream.pipe(process.stdout)
|
||||
|
||||
// Stream from utf8 to hex to base64... Why not, ay.
|
||||
var hex64Stream = fs.createReadStream('myFile')
|
||||
.pipe(strs('utf8', 'hex'))
|
||||
.pipe(strs('hex', 'base64'))
|
||||
|
||||
hex64Stream.pipe(process.stdout)
|
||||
|
||||
// Deals with base64 correctly by aligning chunks
|
||||
var stream = fs.createReadStream('myFile').pipe(strs('base64'))
|
||||
|
||||
var base64Str = ''
|
||||
|
||||
stream.on('data', function(data) { base64Str += data })
|
||||
stream.on('end', function() {
|
||||
console.log('My base64 encoded file is: ' + base64Str) // Wouldn't work with setEncoding()
|
||||
console.log('Original file is: ' + new Buffer(base64Str, 'base64'))
|
||||
})
|
98
node_modules/stringstream/package.json
generated
vendored
Normal file
98
node_modules/stringstream/package.json
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"name": "stringstream",
|
||||
"raw": "stringstream@~0.0.4",
|
||||
"rawSpec": "~0.0.4",
|
||||
"scope": null,
|
||||
"spec": ">=0.0.4 <0.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/root/gitbook/node_modules/phantomjs/node_modules/request"
|
||||
]
|
||||
],
|
||||
"_from": "stringstream@>=0.0.4 <0.1.0",
|
||||
"_hasShrinkwrap": false,
|
||||
"_id": "stringstream@0.0.6",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/stringstream",
|
||||
"_nodeVersion": "8.11.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/stringstream_0.0.6_1526552557136_0.20062352033275022"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "michael.hart.au@gmail.com",
|
||||
"name": "hichaelmart"
|
||||
},
|
||||
"_npmVersion": "6.0.1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "stringstream",
|
||||
"raw": "stringstream@~0.0.4",
|
||||
"rawSpec": "~0.0.4",
|
||||
"scope": null,
|
||||
"spec": ">=0.0.4 <0.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/phantomjs/request"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz",
|
||||
"_shasum": "7880225b0d4ad10e30927d167a1d6f2fd3b33a72",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "stringstream@~0.0.4",
|
||||
"_where": "/root/gitbook/node_modules/phantomjs/node_modules/request",
|
||||
"author": {
|
||||
"email": "michael.hart.au@gmail.com",
|
||||
"name": "Michael Hart",
|
||||
"url": "http://github.com/mhart"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mhart/StringStream/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Encode and decode streams into string streams",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"fileCount": 6,
|
||||
"integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==",
|
||||
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa/VftCRA9TVsSAnZWagAA6KMP/ieCrg0R0w4OF+ptEu5Z\nMatSI7T+xoZAKA+/dHPcLuEBfBT5Dilim5ryW6l7iqnQpBxfLnmSaqLJo5Jg\n9hBb4ojhblFC1FKmL1tSwqCQt9yQN/PHLi5+iWpRSfSubaqSMG5Ryi2HP4Ek\nssanBMdfB++umdRa6KzXHvyxrUnJ2qK1wDV55qnsVR2tBm4H8TO38mRryedE\n4WMd+XQrTICRvGiAsxOBNYylajvZdAKVdP59yNP5C0EzFpXLxd5wtyHYaewL\nVwdUNNYiRkRXSSeV7IWBzaVCf7m/NF7hm9pRXm7k1He3XBeMzlUiLe3h9rw3\nadrGevZdIkuxuddOV57q6bE2ZSWLZjY/7hmuXMPlGxLMxY2sz8UdT5XHS2Ej\nZfmLexQHr+b83I0xkLTDZrV/Ul+xV2gXa+OdFDMakupsB9lOMUlwzt+drE6G\nEKUBnQ8gtXq00z8EWJiPK2s72I4m/3MWztyHKLU7Xh9wOjaZE0YbsUEBZrOD\ndFdkcyU8BwJVpTHR1pnfwMx8xPzeXGsozQkdnCz9MCe8slrI2zGJiaO8WX1h\nLZlUbTGkmQdow1Tr16KMroipZr4Occ9ywvcdRJZ82ZMbK6mZQVPxPOiTM2is\nlHgSChWwuEO/HDwuSJVU02VFEyQAsYdly7EBD2ghYprVFvb9qYJnsINwU2LF\nuIDd\r\n=TTH/\r\n-----END PGP SIGNATURE-----\r\n",
|
||||
"shasum": "7880225b0d4ad10e30927d167a1d6f2fd3b33a72",
|
||||
"signatures": [
|
||||
{
|
||||
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
|
||||
"sig": "MEQCICuip2qHsZS2pXjUP74AfBiDWVCbnfBFyjbQL/CsE7yQAiBs+nFJdGWv4YY6Ta8zETOGmoZu00MSF2jpbhtV3x6sXA=="
|
||||
}
|
||||
],
|
||||
"tarball": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz",
|
||||
"unpackedSize": 6242
|
||||
},
|
||||
"gitHead": "fee31c5c4a5efc7c7cc2fde4aee633dedefd6d67",
|
||||
"homepage": "https://github.com/mhart/StringStream#readme",
|
||||
"keywords": [
|
||||
"string",
|
||||
"stream",
|
||||
"base64",
|
||||
"gzip"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "stringstream.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "michael.hart.au@gmail.com",
|
||||
"name": "hichaelmart"
|
||||
}
|
||||
],
|
||||
"name": "stringstream",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mhart/StringStream.git"
|
||||
},
|
||||
"version": "0.0.6"
|
||||
}
|
102
node_modules/stringstream/stringstream.js
generated
vendored
Normal file
102
node_modules/stringstream/stringstream.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
var util = require('util')
|
||||
var Stream = require('stream')
|
||||
var StringDecoder = require('string_decoder').StringDecoder
|
||||
|
||||
module.exports = StringStream
|
||||
module.exports.AlignedStringDecoder = AlignedStringDecoder
|
||||
|
||||
function StringStream(from, to) {
|
||||
if (!(this instanceof StringStream)) return new StringStream(from, to)
|
||||
|
||||
Stream.call(this)
|
||||
|
||||
if (from == null) from = 'utf8'
|
||||
|
||||
this.readable = this.writable = true
|
||||
this.paused = false
|
||||
this.toEncoding = (to == null ? from : to)
|
||||
this.fromEncoding = (to == null ? '' : from)
|
||||
this.decoder = new AlignedStringDecoder(this.toEncoding)
|
||||
}
|
||||
util.inherits(StringStream, Stream)
|
||||
|
||||
StringStream.prototype.write = function(data) {
|
||||
if (!this.writable) {
|
||||
var err = new Error('stream not writable')
|
||||
err.code = 'EPIPE'
|
||||
this.emit('error', err)
|
||||
return false
|
||||
}
|
||||
if (this.fromEncoding) {
|
||||
if (Buffer.isBuffer(data) || typeof data === 'number') data = data.toString()
|
||||
data = new Buffer(data, this.fromEncoding)
|
||||
}
|
||||
var string = this.decoder.write(data)
|
||||
if (string.length) this.emit('data', string)
|
||||
return !this.paused
|
||||
}
|
||||
|
||||
StringStream.prototype.flush = function() {
|
||||
if (this.decoder.flush) {
|
||||
var string = this.decoder.flush()
|
||||
if (string.length) this.emit('data', string)
|
||||
}
|
||||
}
|
||||
|
||||
StringStream.prototype.end = function() {
|
||||
if (!this.writable && !this.readable) return
|
||||
this.flush()
|
||||
this.emit('end')
|
||||
this.writable = this.readable = false
|
||||
this.destroy()
|
||||
}
|
||||
|
||||
StringStream.prototype.destroy = function() {
|
||||
this.decoder = null
|
||||
this.writable = this.readable = false
|
||||
this.emit('close')
|
||||
}
|
||||
|
||||
StringStream.prototype.pause = function() {
|
||||
this.paused = true
|
||||
}
|
||||
|
||||
StringStream.prototype.resume = function () {
|
||||
if (this.paused) this.emit('drain')
|
||||
this.paused = false
|
||||
}
|
||||
|
||||
function AlignedStringDecoder(encoding) {
|
||||
StringDecoder.call(this, encoding)
|
||||
|
||||
switch (this.encoding) {
|
||||
case 'base64':
|
||||
this.write = alignedWrite
|
||||
this.alignedBuffer = new Buffer(3)
|
||||
this.alignedBytes = 0
|
||||
break
|
||||
}
|
||||
}
|
||||
util.inherits(AlignedStringDecoder, StringDecoder)
|
||||
|
||||
AlignedStringDecoder.prototype.flush = function() {
|
||||
if (!this.alignedBuffer || !this.alignedBytes) return ''
|
||||
var leftover = this.alignedBuffer.toString(this.encoding, 0, this.alignedBytes)
|
||||
this.alignedBytes = 0
|
||||
return leftover
|
||||
}
|
||||
|
||||
function alignedWrite(buffer) {
|
||||
var rem = (this.alignedBytes + buffer.length) % this.alignedBuffer.length
|
||||
if (!rem && !this.alignedBytes) return buffer.toString(this.encoding)
|
||||
|
||||
var returnBuffer = new Buffer(this.alignedBytes + buffer.length - rem)
|
||||
|
||||
this.alignedBuffer.copy(returnBuffer, 0, 0, this.alignedBytes)
|
||||
buffer.copy(returnBuffer, this.alignedBytes, 0, buffer.length - rem)
|
||||
|
||||
buffer.copy(this.alignedBuffer, 0, buffer.length - rem, buffer.length)
|
||||
this.alignedBytes = rem
|
||||
|
||||
return returnBuffer.toString(this.encoding)
|
||||
}
|
Reference in New Issue
Block a user