first commit
This commit is contained in:
26
build/node_modules/base62/.codeclimate.yml
generated
vendored
Normal file
26
build/node_modules/base62/.codeclimate.yml
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
engines:
|
||||
duplication:
|
||||
enabled: true
|
||||
config:
|
||||
languages:
|
||||
- ruby
|
||||
- javascript
|
||||
- python
|
||||
- php
|
||||
eslint:
|
||||
enabled: true
|
||||
fixme:
|
||||
enabled: true
|
||||
ratings:
|
||||
paths:
|
||||
- "**.inc"
|
||||
- "**.js"
|
||||
- "**.jsx"
|
||||
- "**.module"
|
||||
- "**.php"
|
||||
- "**.py"
|
||||
- "**.rb"
|
||||
exclude_paths:
|
||||
- test/
|
||||
- benchmark/
|
||||
1
build/node_modules/base62/.eslintignore
generated
vendored
Normal file
1
build/node_modules/base62/.eslintignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
**/*{.,-}min.js
|
||||
213
build/node_modules/base62/.eslintrc
generated
vendored
Normal file
213
build/node_modules/base62/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
ecmaFeatures:
|
||||
modules: true
|
||||
jsx: true
|
||||
|
||||
env:
|
||||
amd: true
|
||||
browser: true
|
||||
es6: true
|
||||
jquery: true
|
||||
node: true
|
||||
|
||||
# http://eslint.org/docs/rules/
|
||||
rules:
|
||||
# Possible Errors
|
||||
comma-dangle: [2, never]
|
||||
no-cond-assign: 2
|
||||
no-console: 0
|
||||
no-constant-condition: 2
|
||||
no-control-regex: 2
|
||||
no-debugger: 2
|
||||
no-dupe-args: 2
|
||||
no-dupe-keys: 2
|
||||
no-duplicate-case: 2
|
||||
no-empty: 2
|
||||
no-empty-character-class: 2
|
||||
no-ex-assign: 2
|
||||
no-extra-boolean-cast: 2
|
||||
no-extra-parens: 0
|
||||
no-extra-semi: 2
|
||||
no-func-assign: 2
|
||||
no-inner-declarations: [2, functions]
|
||||
no-invalid-regexp: 2
|
||||
no-irregular-whitespace: 2
|
||||
no-negated-in-lhs: 2
|
||||
no-obj-calls: 2
|
||||
no-regex-spaces: 2
|
||||
no-sparse-arrays: 2
|
||||
no-unexpected-multiline: 2
|
||||
no-unreachable: 2
|
||||
use-isnan: 2
|
||||
valid-jsdoc: 0
|
||||
valid-typeof: 2
|
||||
|
||||
# Best Practices
|
||||
accessor-pairs: 2
|
||||
block-scoped-var: 0
|
||||
complexity: [2, 6]
|
||||
consistent-return: 0
|
||||
curly: 0
|
||||
default-case: 0
|
||||
dot-location: 0
|
||||
dot-notation: 0
|
||||
eqeqeq: 2
|
||||
guard-for-in: 2
|
||||
no-alert: 2
|
||||
no-caller: 2
|
||||
no-case-declarations: 2
|
||||
no-div-regex: 2
|
||||
no-else-return: 0
|
||||
no-empty-label: 2
|
||||
no-empty-pattern: 2
|
||||
no-eq-null: 2
|
||||
no-eval: 2
|
||||
no-extend-native: 2
|
||||
no-extra-bind: 2
|
||||
no-fallthrough: 2
|
||||
no-floating-decimal: 0
|
||||
no-implicit-coercion: 0
|
||||
no-implied-eval: 2
|
||||
no-invalid-this: 0
|
||||
no-iterator: 2
|
||||
no-labels: 0
|
||||
no-lone-blocks: 2
|
||||
no-loop-func: 2
|
||||
no-magic-number: 0
|
||||
no-multi-spaces: 0
|
||||
no-multi-str: 0
|
||||
no-native-reassign: 2
|
||||
no-new-func: 2
|
||||
no-new-wrappers: 2
|
||||
no-new: 2
|
||||
no-octal-escape: 2
|
||||
no-octal: 2
|
||||
no-proto: 2
|
||||
no-redeclare: 2
|
||||
no-return-assign: 2
|
||||
no-script-url: 2
|
||||
no-self-compare: 2
|
||||
no-sequences: 0
|
||||
no-throw-literal: 0
|
||||
no-unused-expressions: 2
|
||||
no-useless-call: 2
|
||||
no-useless-concat: 2
|
||||
no-void: 2
|
||||
no-warning-comments: 0
|
||||
no-with: 2
|
||||
radix: 2
|
||||
vars-on-top: 0
|
||||
wrap-iife: 2
|
||||
yoda: 0
|
||||
|
||||
# Strict
|
||||
strict: 0
|
||||
|
||||
# Variables
|
||||
init-declarations: 0
|
||||
no-catch-shadow: 2
|
||||
no-delete-var: 2
|
||||
no-label-var: 2
|
||||
no-shadow-restricted-names: 2
|
||||
no-shadow: 0
|
||||
no-undef-init: 2
|
||||
no-undef: 0
|
||||
no-undefined: 0
|
||||
no-unused-vars: 0
|
||||
no-use-before-define: 0
|
||||
|
||||
# Node.js and CommonJS
|
||||
callback-return: 2
|
||||
global-require: 2
|
||||
handle-callback-err: 2
|
||||
no-mixed-requires: 0
|
||||
no-new-require: 0
|
||||
no-path-concat: 2
|
||||
no-process-exit: 2
|
||||
no-restricted-modules: 0
|
||||
no-sync: 0
|
||||
|
||||
# Stylistic Issues
|
||||
array-bracket-spacing: 0
|
||||
block-spacing: 0
|
||||
brace-style: 0
|
||||
camelcase: 0
|
||||
comma-spacing: 0
|
||||
comma-style: 0
|
||||
computed-property-spacing: 0
|
||||
consistent-this: 0
|
||||
eol-last: 0
|
||||
func-names: 0
|
||||
func-style: 0
|
||||
id-length: 0
|
||||
id-match: 0
|
||||
indent: 0
|
||||
jsx-quotes: 0
|
||||
key-spacing: 0
|
||||
linebreak-style: 0
|
||||
lines-around-comment: 0
|
||||
max-depth: 0
|
||||
max-len: 0
|
||||
max-nested-callbacks: 0
|
||||
max-params: 0
|
||||
max-statements: [2, 30]
|
||||
new-cap: 0
|
||||
new-parens: 0
|
||||
newline-after-var: 0
|
||||
no-array-constructor: 0
|
||||
no-bitwise: 0
|
||||
no-continue: 0
|
||||
no-inline-comments: 0
|
||||
no-lonely-if: 0
|
||||
no-mixed-spaces-and-tabs: 0
|
||||
no-multiple-empty-lines: 0
|
||||
no-negated-condition: 0
|
||||
no-nested-ternary: 0
|
||||
no-new-object: 0
|
||||
no-plusplus: 0
|
||||
no-restricted-syntax: 0
|
||||
no-spaced-func: 0
|
||||
no-ternary: 0
|
||||
no-trailing-spaces: 0
|
||||
no-underscore-dangle: 0
|
||||
no-unneeded-ternary: 0
|
||||
object-curly-spacing: 0
|
||||
one-var: 0
|
||||
operator-assignment: 0
|
||||
operator-linebreak: 0
|
||||
padded-blocks: 0
|
||||
quote-props: 0
|
||||
quotes: 0
|
||||
require-jsdoc: 0
|
||||
semi-spacing: 0
|
||||
semi: 0
|
||||
sort-vars: 0
|
||||
space-after-keywords: 0
|
||||
space-before-blocks: 0
|
||||
space-before-function-paren: 0
|
||||
space-before-keywords: 0
|
||||
space-in-parens: 0
|
||||
space-infix-ops: 0
|
||||
space-return-throw-case: 0
|
||||
space-unary-ops: 0
|
||||
spaced-comment: 0
|
||||
wrap-regex: 0
|
||||
|
||||
# ECMAScript 6
|
||||
arrow-body-style: 0
|
||||
arrow-parens: 0
|
||||
arrow-spacing: 0
|
||||
constructor-super: 0
|
||||
generator-star-spacing: 0
|
||||
no-arrow-condition: 0
|
||||
no-class-assign: 0
|
||||
no-const-assign: 0
|
||||
no-dupe-class-members: 0
|
||||
no-this-before-super: 0
|
||||
no-var: 0
|
||||
object-shorthand: 0
|
||||
prefer-arrow-callback: 0
|
||||
prefer-const: 0
|
||||
prefer-reflect: 0
|
||||
prefer-spread: 0
|
||||
prefer-template: 0
|
||||
require-yield: 0
|
||||
8
build/node_modules/base62/.travis.yml
generated
vendored
Normal file
8
build/node_modules/base62/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "8.7"
|
||||
- "7.10"
|
||||
- "6.10"
|
||||
- "6.3"
|
||||
- "5.2"
|
||||
- "4.1"
|
||||
74
build/node_modules/base62/CODE_OF_CONDUCT.md
generated
vendored
Normal file
74
build/node_modules/base62/CODE_OF_CONDUCT.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at andrewnez@gmail.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
11
build/node_modules/base62/CONTRIBUTING.md
generated
vendored
Normal file
11
build/node_modules/base62/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Contributing
|
||||
|
||||
* Fork the project.
|
||||
* Make your feature addition or bug fix.
|
||||
* Add documentation if necessary.
|
||||
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
||||
* Send a pull request. Bonus points for topic branches.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
||||
20
build/node_modules/base62/LICENSE
generated
vendored
Normal file
20
build/node_modules/base62/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2016 Andrew Nesbitt
|
||||
|
||||
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.
|
||||
68
build/node_modules/base62/Readme.md
generated
vendored
Normal file
68
build/node_modules/base62/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
# [Base62.js](http://libraries.io/npm/base62)
|
||||
[](http://travis-ci.org/andrew/base62.js)
|
||||
[](http://badge.fury.io/js/base62)
|
||||
[](https://david-dm.org/andrew/base62.js#info=devDependencies)
|
||||
[](https://gitter.im/andrew/base62.js)
|
||||
|
||||
A javascript Base62 encode/decoder for node.js
|
||||
|
||||
## What is Base62 encoding?
|
||||
|
||||
From [wikipedia](https://de.wikipedia.org/wiki/Base62):
|
||||
|
||||
> Base62 is a priority system to the base 62, which for encoding large numbers using ASCII is character. The digits 0-9 (value 0-9), uppercase letters A-Z (value 10-35) and lowercase letters a-z (value 36-61) are used.
|
||||
|
||||
> Due to the high number of base formed shorter strings than with the decimal or hexadecimal system , which mainly offers two advantages:
|
||||
|
||||
> - They can be entered by a human being faster and with a smaller risk of error. In this case, a font should be selected in which characters that can be confused, such as small L and large i, or zero, and large O, are distinguishable.
|
||||
> - Length restrictions, eg when a number is to be used as part of an identifier or file name, can be bypassed. However, it should be noted that the processing system is case-sensitive.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install base62
|
||||
```
|
||||
or for yarn:
|
||||
```bash
|
||||
yarn add base62
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### Default Character Set Example
|
||||
|
||||
```javascript
|
||||
Base62 = require('base62')
|
||||
Base62.encode(999) // 'g7'
|
||||
Base62.decode('g7') // 999
|
||||
```
|
||||
|
||||
### Custom Character Set Example
|
||||
|
||||
The default character set is `0-9a-zA-Z`. This can be updated to a custom character set. Naturally, it must be 62 characters long.
|
||||
|
||||
Instead of the character set `0-9a-zA-Z` you want to use `0-9A-Za-z`, call the `setCharacterSet()` method on the Base62 object passing in the string `"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"`. Note that all characters must be unique.
|
||||
|
||||
```javascript
|
||||
Base62 = require('base62')
|
||||
Base62.setCharacterSet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
Base62.encode(999) // 'G7'
|
||||
Base62.decode('G7') // 999
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
Source hosted at [GitHub](http://github.com/andrew/base62.js).
|
||||
Report Issues/Feature requests on [GitHub Issues](http://github.com/andrew/base62.js).
|
||||
|
||||
### Note on Patches/Pull Requests
|
||||
|
||||
* Fork the project.
|
||||
* Make your feature addition or bug fix.
|
||||
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
||||
* Send me a pull request. Bonus points for topic branches.
|
||||
|
||||
## Copyright
|
||||
|
||||
Copyright (c) 2016 Andrew Nesbitt. See [LICENSE](https://github.com/andrew/base62.js/blob/master/LICENSE) for details.
|
||||
76
build/node_modules/base62/base62.js
generated
vendored
Normal file
76
build/node_modules/base62/base62.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
module.exports = (function (Base62) {
|
||||
"use strict";
|
||||
|
||||
var DEFAULT_CHARACTER_SET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
Base62.encode = function(integer){
|
||||
if (integer === 0) {return '0';}
|
||||
var s = '';
|
||||
while (integer > 0) {
|
||||
s = Base62.characterSet[integer % 62] + s;
|
||||
integer = Math.floor(integer/62);
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
var defaultCharsetDecode = function defaultCharsetDecode (base62String) {
|
||||
var value = 0,
|
||||
i = 0,
|
||||
length = base62String.length,
|
||||
charValue;
|
||||
|
||||
for (; i < length; i++) {
|
||||
charValue = base62String.charCodeAt(i);
|
||||
|
||||
if (charValue < 58) {
|
||||
charValue = charValue - 48;
|
||||
} else if (charValue < 91) {
|
||||
charValue = charValue - 29;
|
||||
} else {
|
||||
charValue = charValue - 87;
|
||||
}
|
||||
|
||||
value += charValue * Math.pow(62, length - i - 1);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
var customCharsetDecode = function customCharsetDecode (base62String) {
|
||||
var val = 0,
|
||||
i = 0,
|
||||
length = base62String.length,
|
||||
characterSet = Base62.characterSet;
|
||||
|
||||
for (; i < length; i++) {
|
||||
val += characterSet.indexOf(base62String[i]) * Math.pow(62, length - i - 1);
|
||||
}
|
||||
|
||||
return val;
|
||||
};
|
||||
|
||||
var decodeImplementation = null;
|
||||
|
||||
Base62.decode = function(base62String){
|
||||
return decodeImplementation(base62String);
|
||||
};
|
||||
|
||||
Base62.setCharacterSet = function(chars) {
|
||||
var arrayOfChars = chars.split(""), uniqueCharacters = [];
|
||||
|
||||
if(arrayOfChars.length !== 62) throw Error("You must supply 62 characters");
|
||||
|
||||
arrayOfChars.forEach(function(char){
|
||||
if(!~uniqueCharacters.indexOf(char)) uniqueCharacters.push(char);
|
||||
});
|
||||
|
||||
if(uniqueCharacters.length !== 62) throw Error("You must use unique characters.");
|
||||
|
||||
Base62.characterSet = arrayOfChars;
|
||||
|
||||
decodeImplementation = chars === DEFAULT_CHARACTER_SET ? defaultCharsetDecode : customCharsetDecode;
|
||||
};
|
||||
|
||||
Base62.setCharacterSet(DEFAULT_CHARACTER_SET);
|
||||
return Base62;
|
||||
}({}));
|
||||
64
build/node_modules/base62/benchmark/benchmarks.js
generated
vendored
Normal file
64
build/node_modules/base62/benchmark/benchmarks.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
var base62 = require('../'),
|
||||
now = 0,
|
||||
deltaTime = 0,
|
||||
i = 0,
|
||||
intResult = 0,
|
||||
strResult = 0;
|
||||
|
||||
function performanceNow(){
|
||||
var t = process.hrtime();
|
||||
|
||||
return t[0] * 1000 + t[1] / 1000000;
|
||||
}
|
||||
|
||||
//decode with default charset
|
||||
|
||||
now = performanceNow();
|
||||
|
||||
for (intResult = 0, i = 0; i < 1000000; i++) {
|
||||
intResult += base62.decode('00thing');
|
||||
}
|
||||
|
||||
deltaTime = performanceNow() - now;
|
||||
|
||||
console.log('|', 'decoding with default charset (1000000x)', '|', intResult === 432635954000000 ? 'correct' : 'incorrect', '|', deltaTime.toFixed(2), 'ms', '|');
|
||||
|
||||
//encode with default charset
|
||||
|
||||
now = performanceNow();
|
||||
|
||||
for (strResult = '', i = 0; i < 1000000; i++) {
|
||||
strResult = base62.encode(i);
|
||||
}
|
||||
|
||||
deltaTime = performanceNow() - now;
|
||||
|
||||
console.log('|', 'encoding with default charset (1000000x)', '|', strResult === '4c91' ? 'correct' : 'incorrect', '|', deltaTime.toFixed(2), 'ms', '|');
|
||||
|
||||
//decode with custom charset
|
||||
|
||||
base62.setCharacterSet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
|
||||
|
||||
now = performanceNow();
|
||||
|
||||
for (intResult = 0, i = 0; i < 1000000; i++) {
|
||||
intResult += base62.decode('00thing');
|
||||
}
|
||||
|
||||
deltaTime = performanceNow() - now;
|
||||
|
||||
console.log('|', 'decoding with custom charset (1000000x)', '|', intResult === 823118800000000 ? 'correct' : 'incorrect', '|', deltaTime.toFixed(2), 'ms', '|');
|
||||
|
||||
//encode with custom charset
|
||||
|
||||
now = performanceNow();
|
||||
|
||||
for (strResult = '', i = 0; i < 1000000; i++) {
|
||||
strResult = base62.encode(i);
|
||||
}
|
||||
|
||||
deltaTime = performanceNow() - now;
|
||||
|
||||
console.log('|', 'encoding with custom charset (1000000x)', '|', strResult === '4C91' ? 'correct' : 'incorrect', '|', deltaTime.toFixed(2), 'ms', '|');
|
||||
7
build/node_modules/base62/index.d.ts
generated
vendored
Normal file
7
build/node_modules/base62/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare namespace base62 {
|
||||
export function setCharacterSet(characters: string): void
|
||||
export function encode(number: number): string
|
||||
export function decode(string: string): number
|
||||
}
|
||||
|
||||
export = base62
|
||||
60
build/node_modules/base62/package.json
generated
vendored
Normal file
60
build/node_modules/base62/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"_from": "base62@^1.1.2",
|
||||
"_id": "base62@1.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-xVtfFHNPUzpCNHygpXFGMlDk3saxXLQcOOQzAAk6ibvlAHgT6WKXLv9rMFhcyEK1n9LuDmp/LxyGW/Fm9L8++g==",
|
||||
"_location": "/base62",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "base62@^1.1.2",
|
||||
"name": "base62",
|
||||
"escapedName": "base62",
|
||||
"rawSpec": "^1.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/prepack"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/base62/-/base62-1.2.1.tgz",
|
||||
"_shasum": "95a5a22350b0a557f3f081247fc2c398803ecb0c",
|
||||
"_spec": "base62@^1.1.2",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/prepack",
|
||||
"author": {
|
||||
"name": "Andrew Nesbitt",
|
||||
"email": "andrewnez@gmail.com",
|
||||
"url": "http://nesbitt.io"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/andrew/base62.js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Javascript Base62 encode/decoder",
|
||||
"devDependencies": {
|
||||
"mocha": "~4.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/andrew/base62.js",
|
||||
"keywords": [
|
||||
"base-62",
|
||||
"encoder",
|
||||
"decoder"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "base62.js",
|
||||
"name": "base62",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/andrew/base62.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "node benchmark/benchmarks.js",
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.2.1"
|
||||
}
|
||||
78
build/node_modules/base62/test/test.js
generated
vendored
Normal file
78
build/node_modules/base62/test/test.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
var assert = require('assert');
|
||||
var Base62 = require('../base62');
|
||||
|
||||
describe("encode", function() {
|
||||
it("should encode a number to a Base62 string", function() {
|
||||
assert.equal(Base62.encode(0), '0');
|
||||
assert.equal(Base62.encode(999), 'g7');
|
||||
assert.equal(Base62.encode(65), '13');
|
||||
//test big numbers
|
||||
assert.equal(Base62.encode(10000000000001), "2Q3rKTOF");
|
||||
assert.equal(Base62.encode(10000000000002), "2Q3rKTOG");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe("decode", function() {
|
||||
it("should decode a number from a Base62 string", function() {
|
||||
assert.equal(Base62.decode('0'), 0);
|
||||
assert.equal(Base62.decode('g7'), 999);
|
||||
assert.equal(Base62.decode('13'), 65);
|
||||
//zero padded strings
|
||||
assert.equal(Base62.decode('0013'), 65);
|
||||
//test big numbers
|
||||
assert.equal(Base62.decode("2Q3rKTOF"), 10000000000001);
|
||||
assert.equal(Base62.decode("2Q3rKTOH"), 10000000000003);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setCharacterSequence", function(){
|
||||
it("should update the character sequence", function(){
|
||||
Base62.setCharacterSet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
|
||||
//Test default character set is not intact
|
||||
assert.notEqual(Base62.encode(999), 'g7');
|
||||
|
||||
//Test new character set test cases
|
||||
var testCases = {
|
||||
"G7": 999,
|
||||
"Lxf7": 5234233,
|
||||
"qx": 3283,
|
||||
"29": 133,
|
||||
"1S": 90,
|
||||
"3k": 232,
|
||||
"4I": 266,
|
||||
"2X": 157,
|
||||
"1E": 76,
|
||||
"1L": 83
|
||||
};
|
||||
|
||||
Object.keys(testCases).forEach(function(base62String){
|
||||
assert.equal(Base62.encode(testCases[base62String]), base62String);
|
||||
assert.equal(Base62.decode(base62String), testCases[base62String]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("should throw exceptions on invalid strings", function(){
|
||||
var errorCheck = function(err) {
|
||||
if ( (err instanceof Error) && /value/.test(err) ) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(function(){
|
||||
Base62.setCharacterSet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy");
|
||||
}, /You must supply 62 characters/);
|
||||
|
||||
assert.throws(function(){
|
||||
Base62.setCharacterSet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;");
|
||||
}, /You must supply 62 characters/);
|
||||
|
||||
|
||||
assert.throws(function(){
|
||||
Base62.setCharacterSet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxzz");
|
||||
}, /You must use unique characters/);
|
||||
|
||||
});
|
||||
});
|
||||
133
build/node_modules/base62/yarn.lock
generated
vendored
Normal file
133
build/node_modules/base62/yarn.lock
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
balanced-match@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.8"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
browser-stdout@1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f"
|
||||
|
||||
commander@2.11.0:
|
||||
version "2.11.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"
|
||||
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
|
||||
debug@3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
|
||||
dependencies:
|
||||
ms "2.0.0"
|
||||
|
||||
diff@3.3.1:
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.1.tgz#aa8567a6eed03c531fc89d3f711cd0e5259dec75"
|
||||
|
||||
escape-string-regexp@1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
||||
|
||||
fs.realpath@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||
|
||||
glob@7.1.2:
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
|
||||
dependencies:
|
||||
fs.realpath "^1.0.0"
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "^3.0.4"
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
growl@1.10.3:
|
||||
version "1.10.3"
|
||||
resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.3.tgz#1926ba90cf3edfe2adb4927f5880bc22c66c790f"
|
||||
|
||||
has-flag@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51"
|
||||
|
||||
he@1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
|
||||
|
||||
inflight@^1.0.4:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
||||
dependencies:
|
||||
once "^1.3.0"
|
||||
wrappy "1"
|
||||
|
||||
inherits@2:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||
|
||||
minimatch@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
minimist@0.0.8:
|
||||
version "0.0.8"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
|
||||
|
||||
mkdirp@0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
|
||||
dependencies:
|
||||
minimist "0.0.8"
|
||||
|
||||
mocha@~4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/mocha/-/mocha-4.0.1.tgz#0aee5a95cf69a4618820f5e51fa31717117daf1b"
|
||||
dependencies:
|
||||
browser-stdout "1.3.0"
|
||||
commander "2.11.0"
|
||||
debug "3.1.0"
|
||||
diff "3.3.1"
|
||||
escape-string-regexp "1.0.5"
|
||||
glob "7.1.2"
|
||||
growl "1.10.3"
|
||||
he "1.1.1"
|
||||
mkdirp "0.5.1"
|
||||
supports-color "4.4.0"
|
||||
|
||||
ms@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
|
||||
|
||||
once@^1.3.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||
dependencies:
|
||||
wrappy "1"
|
||||
|
||||
path-is-absolute@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
||||
|
||||
supports-color@4.4.0:
|
||||
version "4.4.0"
|
||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e"
|
||||
dependencies:
|
||||
has-flag "^2.0.0"
|
||||
|
||||
wrappy@1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||
Reference in New Issue
Block a user