summaryrefslogtreecommitdiffstats
path: root/node_modules/cyclist
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/cyclist
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/cyclist')
-rw-r--r--node_modules/cyclist/.npmignore2
-rw-r--r--node_modules/cyclist/.travis.yml5
-rw-r--r--node_modules/cyclist/LICENSE21
-rw-r--r--node_modules/cyclist/README.md43
-rw-r--r--node_modules/cyclist/index.js33
-rw-r--r--node_modules/cyclist/package.json59
-rw-r--r--node_modules/cyclist/test.js37
7 files changed, 200 insertions, 0 deletions
diff --git a/node_modules/cyclist/.npmignore b/node_modules/cyclist/.npmignore
new file mode 100644
index 0000000..19e26d5
--- /dev/null
+++ b/node_modules/cyclist/.npmignore
@@ -0,0 +1,2 @@
+bench
+node_modules
diff --git a/node_modules/cyclist/.travis.yml b/node_modules/cyclist/.travis.yml
new file mode 100644
index 0000000..89d7548
--- /dev/null
+++ b/node_modules/cyclist/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - "0.10"
+ - '0.12'
+ - 'iojs'
diff --git a/node_modules/cyclist/LICENSE b/node_modules/cyclist/LICENSE
new file mode 100644
index 0000000..66a4d2a
--- /dev/null
+++ b/node_modules/cyclist/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 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.
diff --git a/node_modules/cyclist/README.md b/node_modules/cyclist/README.md
new file mode 100644
index 0000000..88c2667
--- /dev/null
+++ b/node_modules/cyclist/README.md
@@ -0,0 +1,43 @@
+# Cyclist
+
+Cyclist is an efficient [cyclic list](http://en.wikipedia.org/wiki/Circular_buffer) implemention for Javascript.
+It is available through npm
+
+```
+npm install cyclist
+```
+
+[![build status](http://img.shields.io/travis/mafintosh/cyclist.svg?style=flat)](http://travis-ci.org/mafintosh/cyclist)
+
+## What?
+
+Cyclist allows you to create a list of fixed size that is cyclic.
+In a cyclist list the element following the last one is the first one.
+This property can be really useful when for example trying to order data
+packets that can arrive out of order over a network stream.
+
+## Usage
+
+``` js
+var cyclist = require('cyclist')
+var list = cyclist(4)
+
+list.put(42, 'hello 42') // store something and index 42
+list.put(43, 'hello 43') // store something and index 43
+
+console.log(list.get(42)) // prints hello 42
+console.log(list.get(46)) // prints hello 42 again since 46 - 42 == list.size
+```
+
+## API
+
+* `cyclist(size)` creates a new buffer
+* `cyclist#get(index)` get an object stored in the buffer
+* `cyclist#put(index,value)` insert an object into the buffer
+* `cyclist#del(index)` delete an object from an index
+* `cyclist#size` property containing current size of buffer
+
+## License
+
+MIT
+
diff --git a/node_modules/cyclist/index.js b/node_modules/cyclist/index.js
new file mode 100644
index 0000000..10b6cd4
--- /dev/null
+++ b/node_modules/cyclist/index.js
@@ -0,0 +1,33 @@
+var twoify = function (n) {
+ if (n && !(n & (n - 1))) return n
+ var p = 1
+ while (p < n) p <<= 1
+ return p
+}
+
+var Cyclist = function (size) {
+ if (!(this instanceof Cyclist)) return new Cyclist(size)
+ size = twoify(size)
+ this.mask = size - 1
+ this.size = size
+ this.values = new Array(size)
+}
+
+Cyclist.prototype.put = function (index, val) {
+ var pos = index & this.mask
+ this.values[pos] = val
+ return pos
+}
+
+Cyclist.prototype.get = function (index) {
+ return this.values[index & this.mask]
+}
+
+Cyclist.prototype.del = function (index) {
+ var pos = index & this.mask
+ var val = this.values[pos]
+ this.values[pos] = undefined
+ return val
+}
+
+module.exports = Cyclist
diff --git a/node_modules/cyclist/package.json b/node_modules/cyclist/package.json
new file mode 100644
index 0000000..1788635
--- /dev/null
+++ b/node_modules/cyclist/package.json
@@ -0,0 +1,59 @@
+{
+ "_from": "cyclist@^1.0.1",
+ "_id": "cyclist@1.0.1",
+ "_inBundle": false,
+ "_integrity": "sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=",
+ "_location": "/cyclist",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "cyclist@^1.0.1",
+ "name": "cyclist",
+ "escapedName": "cyclist",
+ "rawSpec": "^1.0.1",
+ "saveSpec": null,
+ "fetchSpec": "^1.0.1"
+ },
+ "_requiredBy": [
+ "/parallel-transform"
+ ],
+ "_resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz",
+ "_shasum": "596e9698fd0c80e12038c2b82d6eb1b35b6224d9",
+ "_spec": "cyclist@^1.0.1",
+ "_where": "/home/pruss/Dev/3-minute-website/node_modules/parallel-transform",
+ "author": {
+ "name": "Mathias Buus Madsen",
+ "email": "mathiasbuus@gmail.com"
+ },
+ "bugs": {
+ "url": "https://github.com/mafintosh/cyclist/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {},
+ "deprecated": false,
+ "description": "Cyclist is an efficient cyclic list implemention.",
+ "devDependencies": {
+ "standard": "^3.8.0",
+ "tape": "^4.0.0"
+ },
+ "homepage": "https://github.com/mafintosh/cyclist",
+ "keywords": [
+ "circular",
+ "buffer",
+ "ring",
+ "cyclic",
+ "data"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "cyclist",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/mafintosh/cyclist.git"
+ },
+ "scripts": {
+ "test": "standard && tape test.js"
+ },
+ "version": "1.0.1"
+}
diff --git a/node_modules/cyclist/test.js b/node_modules/cyclist/test.js
new file mode 100644
index 0000000..2710a63
--- /dev/null
+++ b/node_modules/cyclist/test.js
@@ -0,0 +1,37 @@
+var tape = require('tape')
+var cyclist = require('./')
+
+tape('basic put and get', function (t) {
+ var list = cyclist(2)
+ list.put(0, 'hello')
+ list.put(1, 'world')
+ t.same(list.get(0), 'hello')
+ t.same(list.get(1), 'world')
+ t.end()
+})
+
+tape('overflow put and get', function (t) {
+ var list = cyclist(2)
+ list.put(0, 'hello')
+ list.put(1, 'world')
+ list.put(2, 'verden')
+ t.same(list.get(0), 'verden')
+ t.same(list.get(1), 'world')
+ t.same(list.get(2), 'verden')
+ t.end()
+})
+
+tape('del', function (t) {
+ var list = cyclist(2)
+ list.put(0, 'hello')
+ t.same(list.get(0), 'hello')
+ list.del(0)
+ t.ok(!list.get(0))
+ t.end()
+})
+
+tape('multiple of two', function (t) {
+ var list = cyclist(3)
+ t.same(list.size, 4)
+ t.end()
+})