esperanto-source 0.6.10 → 0.6.11

Sign up to get free protection for your applications and to get access to all the features.
data/vendor/vlq.js DELETED
@@ -1,99 +0,0 @@
1
- ;(function ( global ) {
2
-
3
- var vlq = { encode: encode, decode: decode },
4
- charToInteger,
5
- integerToChar;
6
-
7
- charToInteger = {};
8
- integerToChar = {};
9
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
10
- charToInteger[ char ] = i;
11
- integerToChar[ i ] = char;
12
- });
13
-
14
- function encode ( value ) {
15
- var result;
16
-
17
- if ( typeof value === 'number' ) {
18
- result = encodeInteger( value );
19
- } else if ( Array.isArray( value ) ) {
20
- result = '';
21
- value.forEach( function ( num ) {
22
- result += encodeInteger( num );
23
- });
24
- } else {
25
- throw new Error( 'vlq.encode accepts an integer or an array of integers' );
26
- }
27
-
28
- return result;
29
- }
30
-
31
- function encodeInteger ( num ) {
32
- var result = '', clamped;
33
-
34
- if ( num < 0 ) {
35
- num = ( -num << 1 ) | 1;
36
- } else {
37
- num <<= 1;
38
- }
39
-
40
- do {
41
- clamped = num & 31;
42
- num >>= 5;
43
-
44
- if ( num > 0 ) {
45
- clamped |= 32;
46
- }
47
-
48
- result += integerToChar[ clamped ];
49
- } while ( num > 0 );
50
-
51
- return result;
52
- }
53
-
54
- function decode ( string ) {
55
- var result = [],
56
- len = string.length,
57
- i,
58
- hasContinuationBit,
59
- shift = 0,
60
- value = 0;
61
-
62
- for ( i = 0; i < len; i += 1 ) {
63
- integer = charToInteger[ string[i] ];
64
-
65
- if ( integer === undefined ) {
66
- throw new Error( 'Invalid character (' + string[i] + ')' );
67
- }
68
-
69
- hasContinuationBit = integer & 32;
70
-
71
- integer &= 31;
72
- value += integer << shift;
73
-
74
- if ( hasContinuationBit ) {
75
- shift += 5;
76
- } else {
77
- shouldNegate = value & 1;
78
- value >>= 1;
79
-
80
- result.push( shouldNegate ? -value : value );
81
-
82
- // reset
83
- value = shift = 0;
84
- }
85
- }
86
-
87
- return result;
88
- }
89
-
90
- // Export as AMD
91
- if ( typeof define === 'function' && define.amd ) {
92
- define( vlq );
93
- } else if ( typeof module !== 'undefined' ) {
94
- module.exports = vlq;
95
- } else {
96
- global.vlq = vlq;
97
- }
98
-
99
- }( typeof window !== 'undefined' ? window : this ));