mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-03-27 17:01:36 +00:00
0.0.1
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.
|
||||
66
node_modules/fast-fifo/README.md
generated
vendored
Normal file
66
node_modules/fast-fifo/README.md
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
# 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.
|
||||
|
||||
#### `bool = q.isEmpty()`
|
||||
|
||||
Returns `true` if the FIFO is empty and false otherwise.
|
||||
|
||||
## 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
|
||||
34
node_modules/fast-fifo/bench.js
generated
vendored
Normal file
34
node_modules/fast-fifo/bench.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
const FastFIFO = require('./')
|
||||
const FIFO = require('fifo')
|
||||
|
||||
run(new FIFO(), 'fifo')
|
||||
run(new FastFIFO(), 'fast-fifo')
|
||||
run(new FIFO(), 'fifo')
|
||||
run(new FastFIFO(), 'fast-fifo')
|
||||
|
||||
function run (q, prefix) {
|
||||
const runs = 1024
|
||||
|
||||
console.time(prefix + ' bulk push and shift')
|
||||
|
||||
for (let j = 0; j < 1e5; j++) {
|
||||
for (let i = 0; i < runs; i++) {
|
||||
q.push(i)
|
||||
}
|
||||
for (let i = 0; i < runs; i++) {
|
||||
q.shift()
|
||||
}
|
||||
}
|
||||
|
||||
console.timeEnd(prefix + ' bulk push and shift')
|
||||
console.time(prefix + ' individual push and shift')
|
||||
|
||||
for (let j = 0; j < 1e5; j++) {
|
||||
for (let i = 0; i < runs; i++) {
|
||||
q.push(i)
|
||||
q.shift()
|
||||
}
|
||||
}
|
||||
|
||||
console.timeEnd(prefix + ' individual push and shift')
|
||||
}
|
||||
29
node_modules/fast-fifo/fixed-size.js
generated
vendored
Normal file
29
node_modules/fast-fifo/fixed-size.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
isEmpty () {
|
||||
return this.buffer[this.btm] === undefined
|
||||
}
|
||||
}
|
||||
32
node_modules/fast-fifo/index.js
generated
vendored
Normal file
32
node_modules/fast-fifo/index.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
||||
|
||||
push (val) {
|
||||
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 () {
|
||||
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
|
||||
}
|
||||
|
||||
isEmpty () {
|
||||
return this.head.isEmpty()
|
||||
}
|
||||
}
|
||||
52
node_modules/fast-fifo/package.json
generated
vendored
Normal file
52
node_modules/fast-fifo/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"_from": "fast-fifo@^1.0.0",
|
||||
"_id": "fast-fifo@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-4VEXmjxLj7sbs8J//cn2qhRap50dGzF5n8fjay8mau+Jn4hxSeR3xPFwxMaQq/pDaq7+KQk0PAbC2+nWDkJrmQ==",
|
||||
"_location": "/fast-fifo",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "fast-fifo@^1.0.0",
|
||||
"name": "fast-fifo",
|
||||
"escapedName": "fast-fifo",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/streamx"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.0.0.tgz",
|
||||
"_shasum": "9bc72e6860347bb045a876d1c5c0af11e9b984e7",
|
||||
"_spec": "fast-fifo@^1.0.0",
|
||||
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/streamx",
|
||||
"author": {
|
||||
"name": "Mathias Buus",
|
||||
"url": "@mafintosh"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/fast-fifo/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "A fast fifo implementation similar to the one powering nextTick in Node.js core",
|
||||
"devDependencies": {
|
||||
"standard": "^12.0.1",
|
||||
"tape": "^4.10.1"
|
||||
},
|
||||
"homepage": "https://github.com/mafintosh/fast-fifo",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "fast-fifo",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mafintosh/fast-fifo.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test.js"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
38
node_modules/fast-fifo/test.js
generated
vendored
Normal file
38
node_modules/fast-fifo/test.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
const tape = require('tape')
|
||||
const FIFO = require('./')
|
||||
|
||||
tape('basic', function (t) {
|
||||
const q = new FIFO()
|
||||
const values = [
|
||||
1,
|
||||
4,
|
||||
4,
|
||||
0,
|
||||
null,
|
||||
{},
|
||||
Math.random(),
|
||||
'',
|
||||
'hello',
|
||||
9,
|
||||
1,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
15,
|
||||
52.2,
|
||||
null
|
||||
]
|
||||
|
||||
t.same(q.shift(), undefined)
|
||||
t.ok(q.isEmpty())
|
||||
for (const value of values) q.push(value)
|
||||
while (!q.isEmpty()) t.same(q.shift(), values.shift())
|
||||
t.same(q.shift(), undefined)
|
||||
t.ok(q.isEmpty())
|
||||
t.end()
|
||||
})
|
||||
Reference in New Issue
Block a user