forked from public/fvtt-cthulhu-eternal
Initial import with skill sheet working
This commit is contained in:
21
node_modules/teex/LICENSE
generated
vendored
Normal file
21
node_modules/teex/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Mathias Buus
|
||||
|
||||
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.
|
31
node_modules/teex/README.md
generated
vendored
Normal file
31
node_modules/teex/README.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# teex
|
||||
|
||||
Turn a readable stream into multiple readable [streamx streams](https://github.com/mafintosh/streamx).
|
||||
|
||||
```
|
||||
npm install teex
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
const tee = require('teex')
|
||||
|
||||
// a, b are readable streams that are "clones"
|
||||
// of someReadableStream. both streams need to
|
||||
// be flowing, for someReadableStream to flow
|
||||
|
||||
const [a, b] = tee(someReadableStream)
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
#### `const streams = tee(s, [howMany])`
|
||||
|
||||
Split a readable stream into multiple streams.
|
||||
The `howMany` argument indicates how many streams
|
||||
to split into and defaults to 2.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
16
node_modules/teex/example.js
generated
vendored
Normal file
16
node_modules/teex/example.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
const tee = require('./')
|
||||
const { Readable } = require('streamx')
|
||||
|
||||
const s = new Readable()
|
||||
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
s.push(Buffer.alloc(1024))
|
||||
}
|
||||
|
||||
const [a, b] = tee(s)
|
||||
|
||||
a.on('data', console.log)
|
||||
|
||||
setTimeout(function () {
|
||||
b.read()
|
||||
}, 1000)
|
52
node_modules/teex/index.js
generated
vendored
Normal file
52
node_modules/teex/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
const { Readable } = require('streamx')
|
||||
|
||||
module.exports = function (s, forks = 2) {
|
||||
const streams = new Array(forks)
|
||||
const status = new Array(forks).fill(true)
|
||||
|
||||
let ended = false
|
||||
|
||||
for (let i = 0; i < forks; i++) {
|
||||
streams[i] = new Readable({
|
||||
read (cb) {
|
||||
const check = !status[i]
|
||||
status[i] = true
|
||||
if (check && allReadable()) s.resume()
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
s.on('end', function () {
|
||||
ended = true
|
||||
for (const stream of streams) stream.push(null)
|
||||
})
|
||||
|
||||
s.on('error', function (err) {
|
||||
for (const stream of streams) stream.destroy(err)
|
||||
})
|
||||
|
||||
s.on('close', function () {
|
||||
if (ended) return
|
||||
for (const stream of streams) stream.destroy()
|
||||
})
|
||||
|
||||
s.on('data', function (data) {
|
||||
let needsPause = false
|
||||
for (let i = 0; i < streams.length; i++) {
|
||||
if (!(status[i] = streams[i].push(data))) {
|
||||
needsPause = true
|
||||
}
|
||||
}
|
||||
if (needsPause) s.pause()
|
||||
})
|
||||
|
||||
return streams
|
||||
|
||||
function allReadable () {
|
||||
for (let j = 0; j < status.length; j++) {
|
||||
if (!status[j]) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
26
node_modules/teex/package.json
generated
vendored
Normal file
26
node_modules/teex/package.json
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "teex",
|
||||
"version": "1.0.1",
|
||||
"description": "Turn a readable stream into multiple readable streamx streams",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"streamx": "^2.12.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "^14.3.4",
|
||||
"tape": "^5.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mafintosh/teex.git"
|
||||
},
|
||||
"author": "Mathias Buus (@mafintosh)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/teex/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mafintosh/teex"
|
||||
}
|
68
node_modules/teex/test.js
generated
vendored
Normal file
68
node_modules/teex/test.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
const tape = require('tape')
|
||||
const tee = require('./')
|
||||
const { Readable } = require('streamx')
|
||||
|
||||
tape('throttled by eachother', function (t) {
|
||||
const r = new Readable()
|
||||
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
r.push(Buffer.alloc(1000))
|
||||
}
|
||||
|
||||
const [a, b] = tee(r)
|
||||
|
||||
let aTicks = 0
|
||||
|
||||
a.on('data', function (data) {
|
||||
aTicks++
|
||||
})
|
||||
|
||||
setTimeout(() => b.read(), 100)
|
||||
|
||||
setTimeout(() => {
|
||||
t.same(aTicks, 18)
|
||||
t.end()
|
||||
}, 200)
|
||||
})
|
||||
|
||||
tape('does not premature destroy', function (t) {
|
||||
const r = new Readable()
|
||||
|
||||
const [a, b] = tee(r)
|
||||
|
||||
r.push('a')
|
||||
r.push('b')
|
||||
r.push('c')
|
||||
r.push(null)
|
||||
|
||||
setTimeout(() => {
|
||||
const aSeen = []
|
||||
const bSeen = []
|
||||
|
||||
a.on('data', function (data) {
|
||||
aSeen.push(data)
|
||||
})
|
||||
a.on('end', function () {
|
||||
aSeen.push(null)
|
||||
})
|
||||
|
||||
b.on('data', function (data) {
|
||||
bSeen.push(data)
|
||||
})
|
||||
b.on('end', function () {
|
||||
bSeen.push(null)
|
||||
})
|
||||
|
||||
let missing = 2
|
||||
a.on('close', onclose)
|
||||
b.on('close', onclose)
|
||||
|
||||
function onclose () {
|
||||
if (--missing === 0) {
|
||||
t.same(aSeen, ['a', 'b', 'c', null])
|
||||
t.same(bSeen, ['a', 'b', 'c', null])
|
||||
t.end()
|
||||
}
|
||||
}
|
||||
}, 200)
|
||||
})
|
Reference in New Issue
Block a user