aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/yeast
diff options
context:
space:
mode:
authorYaroslav De La Peña Smirnov <yaros.rus_89@live.com.mx>2017-11-29 11:44:34 +0300
committerYaroslav De La Peña Smirnov <yaros.rus_89@live.com.mx>2017-11-29 11:44:34 +0300
commit67fdec20726e48ba3a934cb25bb30d47ec4a4f29 (patch)
tree37fd9f4f0b0c20103e1646fc83021e4765de3680 /node_modules/yeast
downloadspanish-checkers-67fdec20726e48ba3a934cb25bb30d47ec4a4f29.tar.gz
spanish-checkers-67fdec20726e48ba3a934cb25bb30d47ec4a4f29.zip
Initial commit, version 0.5.3
Diffstat (limited to 'node_modules/yeast')
-rw-r--r--node_modules/yeast/LICENSE22
-rw-r--r--node_modules/yeast/README.md82
-rw-r--r--node_modules/yeast/index.js68
-rw-r--r--node_modules/yeast/package.json100
4 files changed, 272 insertions, 0 deletions
diff --git a/node_modules/yeast/LICENSE b/node_modules/yeast/LICENSE
new file mode 100644
index 0000000..6dc9316
--- /dev/null
+++ b/node_modules/yeast/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
+
+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/yeast/README.md b/node_modules/yeast/README.md
new file mode 100644
index 0000000..0b0af0d
--- /dev/null
+++ b/node_modules/yeast/README.md
@@ -0,0 +1,82 @@
+# yeast
+
+[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](https://img.shields.io/npm/v/yeast.svg?style=flat-square)](http://browsenpm.org/package/yeast)[![Build Status](https://img.shields.io/travis/unshiftio/yeast/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/yeast)[![Dependencies](https://img.shields.io/david/unshiftio/yeast.svg?style=flat-square)](https://david-dm.org/unshiftio/yeast)[![Coverage Status](https://img.shields.io/coveralls/unshiftio/yeast/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/yeast?branch=master)[![IRC channel](https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](https://webchat.freenode.net/?channels=unshift)
+
+[![Sauce Test Status](https://saucelabs.com/browser-matrix/yeast.svg)](https://saucelabs.com/u/yeast)
+
+Yeast is a unique id generator. It has been primarily designed to generate a
+unique id which can be used for cache busting. A common practice for this is
+to use a timestamp, but there are couple of downsides when using timestamps.
+
+1. The timestamp is already 13 chars long. This might not matter for 1 request
+ but if you make hundreds of them this quickly adds up in bandwidth and
+ processing time.
+2. It's not unique enough. If you generate two stamps right after each other,
+ they would be identical because the timing accuracy is limited to
+ milliseconds.
+
+Yeast solves both of these issues by:
+
+1. Compressing the generated timestamp using a custom `encode()` function that
+ returns a string representation of the number.
+2. Seeding the id in case of collision (when the id is identical to the previous
+ one).
+
+To keep the strings unique it will use the `.` char to separate the generated
+stamp from the seed.
+
+## Installation
+
+The module is intended to be used in browsers as well as in Node.js and is
+therefore released in the npm registry and can be installed using:
+
+```
+npm install --save yeast
+```
+
+## Usage
+
+All the examples assume that this library is initialized as follow:
+
+```js
+'use strict';
+
+var yeast = require('yeast');
+```
+
+To generate an id just call the `yeast` function.
+
+```js
+console.log(yeast(), yeast(), yeast()); // outputs: KyxidwN KyxidwN.0 KyxidwN.1
+
+setTimeout(function () {
+ console.log(yeast()); // outputs: KyxidwO
+});
+```
+
+### yeast.encode(num)
+
+An helper function that returns a string representing the specified number. The
+returned string contains only URL safe characters.
+
+```js
+yeast.encode(+new Date()); // outputs: Kyxjuo1
+```
+
+### yeast.decode(str)
+
+An helper function that returns the integer value specified by the given string.
+This function can be used to retrieve the timestamp from a `yeast` id.
+
+```js
+var id = yeast(); // holds the value: Kyxl1OU
+
+yeast.decode(id); // outputs: 1439816226334
+```
+
+That's all folks. If you have ideas on how we can further compress the ids
+please open an issue!
+
+## License
+
+[MIT](LICENSE)
diff --git a/node_modules/yeast/index.js b/node_modules/yeast/index.js
new file mode 100644
index 0000000..7299762
--- /dev/null
+++ b/node_modules/yeast/index.js
@@ -0,0 +1,68 @@
+'use strict';
+
+var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
+ , length = 64
+ , map = {}
+ , seed = 0
+ , i = 0
+ , prev;
+
+/**
+ * Return a string representing the specified number.
+ *
+ * @param {Number} num The number to convert.
+ * @returns {String} The string representation of the number.
+ * @api public
+ */
+function encode(num) {
+ var encoded = '';
+
+ do {
+ encoded = alphabet[num % length] + encoded;
+ num = Math.floor(num / length);
+ } while (num > 0);
+
+ return encoded;
+}
+
+/**
+ * Return the integer value specified by the given string.
+ *
+ * @param {String} str The string to convert.
+ * @returns {Number} The integer value represented by the string.
+ * @api public
+ */
+function decode(str) {
+ var decoded = 0;
+
+ for (i = 0; i < str.length; i++) {
+ decoded = decoded * length + map[str.charAt(i)];
+ }
+
+ return decoded;
+}
+
+/**
+ * Yeast: A tiny growing id generator.
+ *
+ * @returns {String} A unique id.
+ * @api public
+ */
+function yeast() {
+ var now = encode(+new Date());
+
+ if (now !== prev) return seed = 0, prev = now;
+ return now +'.'+ encode(seed++);
+}
+
+//
+// Map each character to its index.
+//
+for (; i < length; i++) map[alphabet[i]] = i;
+
+//
+// Expose the `yeast`, `encode` and `decode` functions.
+//
+yeast.encode = encode;
+yeast.decode = decode;
+module.exports = yeast;
diff --git a/node_modules/yeast/package.json b/node_modules/yeast/package.json
new file mode 100644
index 0000000..3cb20d4
--- /dev/null
+++ b/node_modules/yeast/package.json
@@ -0,0 +1,100 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "yeast@0.1.2",
+ "scope": null,
+ "escapedName": "yeast",
+ "name": "yeast",
+ "rawSpec": "0.1.2",
+ "spec": "0.1.2",
+ "type": "version"
+ },
+ "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io-client"
+ ]
+ ],
+ "_from": "yeast@0.1.2",
+ "_id": "yeast@0.1.2",
+ "_inCache": true,
+ "_location": "/yeast",
+ "_nodeVersion": "0.12.3",
+ "_npmUser": {
+ "name": "3rdeden",
+ "email": "npm@3rd-Eden.com"
+ },
+ "_npmVersion": "2.9.1",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "yeast@0.1.2",
+ "scope": null,
+ "escapedName": "yeast",
+ "name": "yeast",
+ "rawSpec": "0.1.2",
+ "spec": "0.1.2",
+ "type": "version"
+ },
+ "_requiredBy": [
+ "/engine.io-client"
+ ],
+ "_resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
+ "_shasum": "008e06d8094320c372dbc2f8ed76a0ca6c8ac419",
+ "_shrinkwrap": null,
+ "_spec": "yeast@0.1.2",
+ "_where": "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io-client",
+ "author": {
+ "name": "Arnout Kazemier"
+ },
+ "bugs": {
+ "url": "https://github.com/unshiftio/yeast/issues"
+ },
+ "dependencies": {},
+ "description": "Tiny but linear growing unique id generator",
+ "devDependencies": {
+ "assume": "1.3.x",
+ "istanbul": "0.3.x",
+ "mocha": "2.3.x",
+ "pre-commit": "1.1.x",
+ "zuul": "3.4.x"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "008e06d8094320c372dbc2f8ed76a0ca6c8ac419",
+ "tarball": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz"
+ },
+ "gitHead": "5a7300f934302009aa8733fa84d43cc570756b98",
+ "homepage": "https://github.com/unshiftio/yeast",
+ "keywords": [
+ "yeast",
+ "id",
+ "generator",
+ "unique"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "unshift",
+ "email": "npm@unshift.io"
+ },
+ {
+ "name": "3rdeden",
+ "email": "npm@3rd-Eden.com"
+ }
+ ],
+ "name": "yeast",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/unshiftio/yeast.git"
+ },
+ "scripts": {
+ "100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
+ "coverage": "istanbul cover _mocha -- test.js",
+ "test": "mocha test.js",
+ "test-browser": "zuul -- test.js",
+ "test-node": "istanbul cover _mocha --report lcovonly -- test.js",
+ "watch": "mocha --watch test.js"
+ },
+ "version": "0.1.2"
+}