bl 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +5 -1
- package/bl.js +9 -7
- package/package.json +14 -4
- package/{test.js → test/basic-test.js} +23 -23
- package/test/sauce.js +38 -0
- package/test/test.js +9 -0
package/.travis.yml
CHANGED
|
@@ -8,4 +8,8 @@ branches:
|
|
|
8
8
|
notifications:
|
|
9
9
|
email:
|
|
10
10
|
- rod@vagg.org
|
|
11
|
-
script: npm test
|
|
11
|
+
script: npm test
|
|
12
|
+
env:
|
|
13
|
+
global:
|
|
14
|
+
- SAUCE_USER=bl-sauce
|
|
15
|
+
- secure: "EN/BSk+c4E8pgtW/hTSk5dp3iBng6PPtWHc2kxeMyUjMCYTjD4/zgZXm/gPTcuBxWByDlFrHlJ9A6L+aj5r9n/48tBJJLJ6B2WezZMAnzo4HHzl445BmSI6MbqmUbrN3nQ+lmRXIUzatW+pyoP+DWgCcLJpXtdKN7LwgIxIQS2g="
|
package/bl.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var DuplexStream = require('readable-stream').Duplex
|
|
2
|
+
, util = require('util')
|
|
3
3
|
|
|
4
4
|
function BufferList (callback) {
|
|
5
5
|
if (!(this instanceof BufferList))
|
|
@@ -195,11 +195,13 @@ BufferList.prototype.duplicate = function () {
|
|
|
195
195
|
, 'readUInt8' : 1
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
for (var m in methods) {
|
|
199
|
+
(function (m) {
|
|
200
|
+
BufferList.prototype[m] = function (offset) {
|
|
201
|
+
return this.slice(offset, offset + methods[m])[m](0)
|
|
202
|
+
}
|
|
203
|
+
}(m))
|
|
204
|
+
}
|
|
203
205
|
}())
|
|
204
206
|
|
|
205
207
|
module.exports = BufferList
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
|
|
5
5
|
"main": "bl.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
7
|
+
"test": "node test/test.js | faucet",
|
|
8
|
+
"test-local": "brtapsauce-local test/basic-test.js"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
@@ -25,8 +26,17 @@
|
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"readable-stream": "~1.0.2"
|
|
27
28
|
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"stream-browserify": "*"
|
|
31
|
+
},
|
|
28
32
|
"devDependencies": {
|
|
29
|
-
"tape": "
|
|
30
|
-
"hash_file": "
|
|
33
|
+
"tape": "~2.3.2",
|
|
34
|
+
"hash_file": "~0.1.1",
|
|
35
|
+
"brtapsauce": "~0.3.0",
|
|
36
|
+
"faucet": "0.0.0",
|
|
37
|
+
"stream-browserify": "~0.1.2"
|
|
38
|
+
},
|
|
39
|
+
"browser": {
|
|
40
|
+
"readable-stream": "stream-browserify"
|
|
31
41
|
}
|
|
32
42
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var tape = require('tape')
|
|
2
|
+
, crypto = require('crypto')
|
|
3
|
+
, fs = require('fs')
|
|
4
|
+
, hash = require('hash_file')
|
|
5
|
+
, BufferList = require('../')
|
|
6
|
+
|
|
7
|
+
, encodings =
|
|
8
|
+
('hex utf8 utf-8 ascii binary base64'
|
|
9
|
+
+ (process.browser ? '' : ' ucs2 ucs-2 utf16le utf-16le')).split(' ')
|
|
6
10
|
|
|
7
11
|
tape('single bytes from single buffer', function (t) {
|
|
8
12
|
var bl = new BufferList()
|
|
@@ -254,17 +258,15 @@ tape('test toString encoding', function (t) {
|
|
|
254
258
|
bl.append(new Buffer('j'))
|
|
255
259
|
bl.append(new Buffer('\xff\x00'))
|
|
256
260
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
.forEach(function (enc) {
|
|
260
|
-
t.equal(bl.toString(enc), b.toString(enc))
|
|
261
|
+
encodings.forEach(function (enc) {
|
|
262
|
+
t.equal(bl.toString(enc), b.toString(enc), enc)
|
|
261
263
|
})
|
|
262
264
|
|
|
263
265
|
t.end()
|
|
264
266
|
})
|
|
265
267
|
|
|
266
|
-
tape('test stream', function (t) {
|
|
267
|
-
var random = crypto.randomBytes(
|
|
268
|
+
!process.browser && tape('test stream', function (t) {
|
|
269
|
+
var random = crypto.randomBytes(65534)
|
|
268
270
|
, rndhash = hash(random, 'md5')
|
|
269
271
|
, md5sum = crypto.createHash('md5')
|
|
270
272
|
, bl = new BufferList(function (err, buf) {
|
|
@@ -294,9 +296,9 @@ tape('instantiation with Buffer', function (t) {
|
|
|
294
296
|
, buf2 = crypto.randomBytes(1024)
|
|
295
297
|
, b = BufferList(buf)
|
|
296
298
|
|
|
297
|
-
t.equal(
|
|
299
|
+
t.equal(buf.toString('hex'), b.slice().toString('hex'), 'same buffer')
|
|
298
300
|
b = BufferList([ buf, buf2 ])
|
|
299
|
-
t.equal(
|
|
301
|
+
t.equal(b.slice().toString('hex'), Buffer.concat([ buf, buf2 ]).toString('hex'), 'same buffer')
|
|
300
302
|
t.end()
|
|
301
303
|
})
|
|
302
304
|
|
|
@@ -310,9 +312,7 @@ tape('test String appendage', function (t) {
|
|
|
310
312
|
bl.append('j')
|
|
311
313
|
bl.append('\xff\x00')
|
|
312
314
|
|
|
313
|
-
|
|
314
|
-
.split(' ')
|
|
315
|
-
.forEach(function (enc) {
|
|
315
|
+
encodings.forEach(function (enc) {
|
|
316
316
|
t.equal(bl.toString(enc), b.toString(enc))
|
|
317
317
|
})
|
|
318
318
|
|
|
@@ -361,7 +361,7 @@ tape('basic copy', function (t) {
|
|
|
361
361
|
, b = BufferList(buf)
|
|
362
362
|
|
|
363
363
|
b.copy(buf2)
|
|
364
|
-
t.equal(
|
|
364
|
+
t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
365
365
|
t.end()
|
|
366
366
|
})
|
|
367
367
|
|
|
@@ -372,7 +372,7 @@ tape('copy after many appends', function (t) {
|
|
|
372
372
|
|
|
373
373
|
b.append(buf)
|
|
374
374
|
b.copy(buf2)
|
|
375
|
-
t.equal(
|
|
375
|
+
t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
376
376
|
t.end()
|
|
377
377
|
})
|
|
378
378
|
|
|
@@ -382,7 +382,7 @@ tape('copy at a precise position', function (t) {
|
|
|
382
382
|
, b = BufferList(buf)
|
|
383
383
|
|
|
384
384
|
b.copy(buf2, 20)
|
|
385
|
-
t.equal(
|
|
385
|
+
t.equal(b.slice().toString('hex'), buf2.slice(20).toString('hex'), 'same buffer')
|
|
386
386
|
t.end()
|
|
387
387
|
})
|
|
388
388
|
|
|
@@ -392,7 +392,7 @@ tape('copy starting from a precise location', function (t) {
|
|
|
392
392
|
, b = BufferList(buf)
|
|
393
393
|
|
|
394
394
|
b.copy(buf2, 0, 5)
|
|
395
|
-
t.equal(
|
|
395
|
+
t.equal(b.slice(5).toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
396
396
|
t.end()
|
|
397
397
|
})
|
|
398
398
|
|
|
@@ -407,7 +407,7 @@ tape('copy in an interval', function (t) {
|
|
|
407
407
|
buf.copy(expected, 0, 5, 7)
|
|
408
408
|
|
|
409
409
|
b.copy(buf2, 0, 5, 7)
|
|
410
|
-
t.equal(
|
|
410
|
+
t.equal(expected.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
411
411
|
t.end()
|
|
412
412
|
})
|
|
413
413
|
|
|
@@ -419,7 +419,7 @@ tape('copy an interval between two buffers', function (t) {
|
|
|
419
419
|
b.append(buf)
|
|
420
420
|
b.copy(buf2, 0, 5, 15)
|
|
421
421
|
|
|
422
|
-
t.equal(
|
|
422
|
+
t.equal(b.slice(5, 15).toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
423
423
|
t.end()
|
|
424
424
|
})
|
|
425
425
|
|
|
@@ -433,7 +433,7 @@ tape('duplicate', function (t) {
|
|
|
433
433
|
t.equal(bl.toString('hex'), dup.toString('hex'))
|
|
434
434
|
})
|
|
435
435
|
|
|
436
|
-
tape('handle error', function (t) {
|
|
436
|
+
!process.browser && tape('handle error', function (t) {
|
|
437
437
|
t.plan(2)
|
|
438
438
|
fs.createReadStream('/does/not/exist').pipe(BufferList(function (err, data) {
|
|
439
439
|
t.ok(err instanceof Error, 'has error')
|
package/test/sauce.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const user = process.env.SAUCE_USER
|
|
4
|
+
, key = process.env.SAUCE_KEY
|
|
5
|
+
, path = require('path')
|
|
6
|
+
, brtapsauce = require('brtapsauce')
|
|
7
|
+
, testFile = path.join(__dirname, 'basic-test.js')
|
|
8
|
+
|
|
9
|
+
, capabilities = [
|
|
10
|
+
{ browserName: 'chrome' , platform: 'Windows XP', version: '' }
|
|
11
|
+
, { browserName: 'firefox' , platform: 'Windows 8' , version: '' }
|
|
12
|
+
, { browserName: 'firefox' , platform: 'Windows XP', version: '4' }
|
|
13
|
+
, { browserName: 'internet explorer' , platform: 'Windows 8' , version: '10' }
|
|
14
|
+
, { browserName: 'internet explorer' , platform: 'Windows 7' , version: '9' }
|
|
15
|
+
, { browserName: 'internet explorer' , platform: 'Windows 7' , version: '8' }
|
|
16
|
+
, { browserName: 'internet explorer' , platform: 'Windows XP', version: '7' }
|
|
17
|
+
, { browserName: 'internet explorer' , platform: 'Windows XP', version: '6' }
|
|
18
|
+
, { browserName: 'safari' , platform: 'Windows 7' , version: '5' }
|
|
19
|
+
, { browserName: 'safari' , platform: 'OS X 10.8' , version: '6' }
|
|
20
|
+
, { browserName: 'opera' , platform: 'Windows 7' , version: '' }
|
|
21
|
+
, { browserName: 'opera' , platform: 'Windows 7' , version: '11' }
|
|
22
|
+
, { browserName: 'ipad' , platform: 'OS X 10.8' , version: '6' }
|
|
23
|
+
, { browserName: 'android' , platform: 'Linux' , version: '4.0', 'device-type': 'tablet' }
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
if (!user)
|
|
27
|
+
throw new Error('Must set a SAUCE_USER env var')
|
|
28
|
+
if (!key)
|
|
29
|
+
throw new Error('Must set a SAUCE_KEY env var')
|
|
30
|
+
|
|
31
|
+
brtapsauce({
|
|
32
|
+
name : 'Traversty'
|
|
33
|
+
, user : user
|
|
34
|
+
, key : key
|
|
35
|
+
, brsrc : testFile
|
|
36
|
+
, capabilities : capabilities
|
|
37
|
+
, options : { timeout: 60 * 6 }
|
|
38
|
+
})
|
package/test/test.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require('./basic-test')
|
|
2
|
+
|
|
3
|
+
if (!process.env.SAUCE_KEY || !process.env.SAUCE_USER)
|
|
4
|
+
return console.log('SAUCE_KEY and/or SAUCE_USER not set, not running sauce tests')
|
|
5
|
+
|
|
6
|
+
if (!/v0\.10/.test(process.version))
|
|
7
|
+
return console.log('Not Node v0.10.x, not running sauce tests')
|
|
8
|
+
|
|
9
|
+
require('./sauce.js')
|