Initial
This commit is contained in:
21
resources/app/node_modules/fast-fifo/LICENSE
generated
vendored
Normal file
21
resources/app/node_modules/fast-fifo/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 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.
|
||||
39
resources/app/node_modules/fast-fifo/fixed-size.js
generated
vendored
Normal file
39
resources/app/node_modules/fast-fifo/fixed-size.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
module.exports = class FixedFIFO {
|
||||
constructor (hwm) {
|
||||
if (!(hwm > 0) || ((hwm - 1) & hwm) !== 0) throw new Error('Max size for a FixedFIFO should be a power of two')
|
||||
this.buffer = new Array(hwm)
|
||||
this.mask = hwm - 1
|
||||
this.top = 0
|
||||
this.btm = 0
|
||||
this.next = null
|
||||
}
|
||||
|
||||
clear () {
|
||||
this.top = this.btm = 0
|
||||
this.next = null
|
||||
this.buffer.fill(undefined)
|
||||
}
|
||||
|
||||
push (data) {
|
||||
if (this.buffer[this.top] !== undefined) return false
|
||||
this.buffer[this.top] = data
|
||||
this.top = (this.top + 1) & this.mask
|
||||
return true
|
||||
}
|
||||
|
||||
shift () {
|
||||
const last = this.buffer[this.btm]
|
||||
if (last === undefined) return undefined
|
||||
this.buffer[this.btm] = undefined
|
||||
this.btm = (this.btm + 1) & this.mask
|
||||
return last
|
||||
}
|
||||
|
||||
peek () {
|
||||
return this.buffer[this.btm]
|
||||
}
|
||||
|
||||
isEmpty () {
|
||||
return this.buffer[this.btm] === undefined
|
||||
}
|
||||
}
|
||||
48
resources/app/node_modules/fast-fifo/index.js
generated
vendored
Normal file
48
resources/app/node_modules/fast-fifo/index.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
const FixedFIFO = require('./fixed-size')
|
||||
|
||||
module.exports = class FastFIFO {
|
||||
constructor (hwm) {
|
||||
this.hwm = hwm || 16
|
||||
this.head = new FixedFIFO(this.hwm)
|
||||
this.tail = this.head
|
||||
this.length = 0
|
||||
}
|
||||
|
||||
clear () {
|
||||
this.head = this.tail
|
||||
this.head.clear()
|
||||
this.length = 0
|
||||
}
|
||||
|
||||
push (val) {
|
||||
this.length++
|
||||
if (!this.head.push(val)) {
|
||||
const prev = this.head
|
||||
this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length)
|
||||
this.head.push(val)
|
||||
}
|
||||
}
|
||||
|
||||
shift () {
|
||||
if (this.length !== 0) this.length--
|
||||
const val = this.tail.shift()
|
||||
if (val === undefined && this.tail.next) {
|
||||
const next = this.tail.next
|
||||
this.tail.next = null
|
||||
this.tail = next
|
||||
return this.tail.shift()
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
peek () {
|
||||
const val = this.tail.peek()
|
||||
if (val === undefined && this.tail.next) return this.tail.next.peek()
|
||||
return val
|
||||
}
|
||||
|
||||
isEmpty () {
|
||||
return this.length === 0
|
||||
}
|
||||
}
|
||||
22
resources/app/node_modules/fast-fifo/package.json
generated
vendored
Normal file
22
resources/app/node_modules/fast-fifo/package.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "fast-fifo",
|
||||
"version": "1.3.2",
|
||||
"description": "A fast fifo implementation similar to the one powering nextTick in Node.js core",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"./index.js",
|
||||
"./fixed-size.js"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"standard": "^17.1.0",
|
||||
"brittle": "^3.3.2"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mafintosh/fast-fifo.git"
|
||||
},
|
||||
"author": "Mathias Buus (@mafintosh)",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/mafintosh/fast-fifo"
|
||||
}
|
||||
Reference in New Issue
Block a user