Initial import with skill sheet working
This commit is contained in:
21
node_modules/fast-fifo/LICENSE
generated
vendored
Normal file
21
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.
|
78
node_modules/fast-fifo/README.md
generated
vendored
Normal file
78
node_modules/fast-fifo/README.md
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
# fast-fifo
|
||||
|
||||
A fast fifo implementation similar to the one powering nextTick in Node.js core
|
||||
|
||||
```
|
||||
npm install fast-fifo
|
||||
```
|
||||
|
||||
Uses a linked list of growing fixed sized arrays to implement the FIFO to avoid
|
||||
allocating a wrapper object for each item.
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
const FIFO = require('fast-fifo')
|
||||
|
||||
const q = new FIFO()
|
||||
|
||||
q.push('hello')
|
||||
q.push('world')
|
||||
|
||||
q.shift() // returns hello
|
||||
q.shift() // returns world
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
#### `q = new FIFO()`
|
||||
|
||||
Create a new FIFO.
|
||||
|
||||
#### `q.push(value)`
|
||||
|
||||
Push a value to the FIFO. `value` can be anything other than undefined.
|
||||
|
||||
#### `value = q.shift()`
|
||||
|
||||
Return the oldest value from the FIFO.
|
||||
|
||||
#### `q.clear()`
|
||||
|
||||
Remove all values from the FIFO.
|
||||
|
||||
#### `bool = q.isEmpty()`
|
||||
|
||||
Returns `true` if the FIFO is empty and false otherwise.
|
||||
|
||||
#### `value = q.peek()`
|
||||
|
||||
Return the oldest value from the FIFO without shifting it out.
|
||||
|
||||
#### `len = q.length`
|
||||
|
||||
Get the number of entries remaining in the FIFO.
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Included in bench.js is a simple benchmark that benchmarks this against a simple
|
||||
linked list based FIFO.
|
||||
|
||||
On my machine the benchmark looks like this:
|
||||
|
||||
```
|
||||
fifo bulk push and shift: 2881.508ms
|
||||
fifo individual push and shift: 3248.437ms
|
||||
fast-fifo bulk push and shift: 1606.972ms
|
||||
fast-fifo individual push and shift: 1328.064ms
|
||||
fifo bulk push and shift: 3266.902ms
|
||||
fifo individual push and shift: 3320.944ms
|
||||
fast-fifo bulk push and shift: 1858.307ms
|
||||
fast-fifo individual push and shift: 1516.983ms
|
||||
```
|
||||
|
||||
YMMV
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
39
node_modules/fast-fifo/fixed-size.js
generated
vendored
Normal file
39
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
node_modules/fast-fifo/index.js
generated
vendored
Normal file
48
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
|
||||
}
|
||||
}
|
28
node_modules/fast-fifo/package.json
generated
vendored
Normal file
28
node_modules/fast-fifo/package.json
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"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"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && brittle test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mafintosh/fast-fifo.git"
|
||||
},
|
||||
"author": "Mathias Buus (@mafintosh)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/fast-fifo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mafintosh/fast-fifo"
|
||||
}
|
Reference in New Issue
Block a user