Skip to content

Commit b6b0517

Browse files
committed
eslint fixes
1 parent 65f73a9 commit b6b0517

File tree

2 files changed

+55
-22
lines changed

2 files changed

+55
-22
lines changed

.eslintrc.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
parserOptions:
2+
ecmaVersion: 2016
3+
env:
4+
node: true
5+
mocha: true
6+
es6: true
7+
extends: eslint:recommended
8+
rules:
9+
quotes: [ 1, "single" ]
10+
semi: [ 1, "never" ]
11+
eqeqeq: 1
12+
no-alert: 2
13+
no-else-return: 2
14+
no-eval: 2
15+
no-extra-semi: 2
16+
17+
# no-global-assign: 2
18+
# no-implicit-globals: 2
19+
no-implicit-coercion: 2
20+
no-implied-eval: 2
21+
no-loop-func: 2
22+
no-redeclare: 2
23+
no-throw-literal: 2
24+
yoda: [ 2, "never" ]
25+
no-unused-vars: 2
26+
no-nested-ternary: 2
27+
28+
array-bracket-spacing: [ 1, "always" ]
29+
block-spacing: [ 1, "always" ]
30+
31+
parser: babel-eslint
32+

index.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
"use strict";
1+
'use strict';
2+
/* global window */
23

34
(function(){
45

5-
var buf;
6-
var str = '';
7-
var strIdx = 0;
8-
var i;
6+
var buf
7+
var str = ''
8+
var strIdx = 0
9+
var i
910
var chars = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1011

1112
// Reduce calls to `crypto` by increasing this number (>=16)
1213
// Uses a tiny bit more memory to store the random bytes (try 16384)
13-
var BUFFER_SIZE = 8192;
14+
var BUFFER_SIZE = 8192
1415

1516

1617
// Binary uuids (even faster)
1718

1819
// Test for uuid
19-
base62.test = isbase62;
20+
base62.test = isbase62
2021
base62.generateBase62Math = generateBase62Math
2122
base62.generateBase62Node = generateBase62Node
2223
base62.generateBase62Browser = generateBase62Browser
@@ -26,28 +27,28 @@
2627

2728
// Node & Browser support
2829
if ((typeof module !== 'undefined') && (typeof require === 'function')) {
29-
var crypto = require('crypto');
30-
module.exports = base62;
30+
var crypto = require('crypto')
31+
module.exports = base62
3132
} else if (typeof window !== 'undefined') {
32-
window.base62 = base62;
33+
window.base62 = base62
3334
}
3435

3536
// Backup method
3637
function getRandomChar() {
37-
return chars[Math.floor(Math.random() * (62 - 0)) + 0];
38+
return chars[Math.floor(Math.random() * (62 - 0)) + 0]
3839
}
3940

4041
// base62.test
4142
function isbase62(str) {
4243
if (typeof str === 'string') {
43-
return /^[0-9a-zA-Z]+$/.test(str);
44+
return /^[0-9a-zA-Z]+$/.test(str)
4445
}
4546
return false
4647
}
4748

4849
function generateBase62Math(){
4950
for (i = 0; i < BUFFER_SIZE; i++) {
50-
buf[i] = getRandomChar();
51+
buf[i] = getRandomChar()
5152
}
5253
strIdx = 0
5354
return str = buf.join('')
@@ -56,33 +57,33 @@
5657
function generateBase62Node(){
5758
//console.error('generating str',strIdx)
5859
strIdx = 0
59-
return str = crypto.randomBytes(BUFFER_SIZE).toString('base64').replace(/[\+\=\/]/g,'');
60+
return str = crypto.randomBytes(BUFFER_SIZE).toString('base64').replace(/[\+\=\/]/g,'')
6061
}
6162

6263
// https://github.com/beatgammit/base64-js
6364
function generateBase62Browser(){
64-
buf = crypto.getRandomValues(buf);
65+
buf = crypto.getRandomValues(buf)
6566
var tmp = Array(BUFFER_SIZE)
6667
for (i=0; i<BUFFER_SIZE; i++){
6768
// wastes some bits, some bit pushing should save the extra 4
68-
tmp.push(chars[buf[i] % 62]);
69+
tmp.push(chars[buf[i] % 62])
6970
}
7071
strIdx = 0
71-
return str = tmp.join('');
72+
return str = tmp.join('')
7273
}
7374

7475
// Use best RNG as possible
75-
var generateBase62;
76+
var generateBase62
7677
strIdx = BUFFER_SIZE
7778

7879
function initMath(){
7980
str = ''
80-
buf = new Array(BUFFER_SIZE);
81+
buf = new Array(BUFFER_SIZE)
8182
generateBase62 = generateBase62Math
8283
}
8384
function initBrowser(){
8485
str = ''
85-
buf = new Uint8Array(BUFFER_SIZE);
86+
buf = new Uint8Array(BUFFER_SIZE)
8687
generateBase62 = generateBase62Browser
8788
}
8889
function initNode(){
@@ -100,7 +101,7 @@
100101
initNode()
101102
}
102103
else {
103-
throw new Error('Non-standard crypto library');
104+
throw new Error('Non-standard crypto library')
104105
}
105106

106107

@@ -110,4 +111,4 @@
110111
return str.slice(strIdx, (strIdx+=length))
111112
}
112113

113-
})();
114+
})()

0 commit comments

Comments
 (0)