@@ -12,11 +12,12 @@ var _createClass2 = require('babel-runtime/helpers/createClass');
1212
1313var _createClass3 = _interopRequireDefault ( _createClass2 ) ;
1414
15- var _charSet = require ( './charSet' ) ;
15+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
1616
17- var _charSet2 = _interopRequireDefault ( _charSet ) ;
17+ var CharSet = require ( './charset' ) . default ;
1818
19- function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
19+ var _require = require ( './charset' ) ,
20+ charset32 = _require . charset32 ;
2021
2122var Crypto = require ( 'crypto' ) ;
2223var WeakMap = require ( 'weak-map' ) ;
@@ -32,12 +33,12 @@ var endianByteNum = function () {
3233 return buf8 [ 0 ] === 0xff ? [ 2 , 3 , 4 , 5 , 6 , 7 ] : [ 0 , 1 , 2 , 3 , 6 , 7 ] ;
3334} ( ) ;
3435
35- var _stringWithBytes = function _stringWithBytes ( entropyBits , bytes , charSet ) {
36+ var _stringWithBytes = function _stringWithBytes ( entropyBits , bytes , charset ) {
3637 if ( entropyBits <= 0 ) {
3738 return '' ;
3839 }
3940
40- var bitsPerChar = charSet . getBitsPerChar ( ) ;
41+ var bitsPerChar = charset . getBitsPerChar ( ) ;
4142 var count = Math . ceil ( entropyBits / bitsPerChar ) ;
4243 if ( count <= 0 ) {
4344 return '' ;
@@ -48,12 +49,12 @@ var _stringWithBytes = function _stringWithBytes(entropyBits, bytes, charSet) {
4849 throw new Error ( 'Insufficient bytes: need ' + need + ' and got ' + bytes . length ) ;
4950 }
5051
51- var charsPerChunk = charSet . getCharsPerChunk ( ) ;
52+ var charsPerChunk = charset . getCharsPerChunk ( ) ;
5253 var chunks = Math . floor ( count / charsPerChunk ) ;
5354 var partials = count % charsPerChunk ;
5455
55- var ndxFn = charSet . getNdxFn ( ) ;
56- var chars = charSet . getChars ( ) ;
56+ var ndxFn = charset . getNdxFn ( ) ;
57+ var chars = charset . getChars ( ) ;
5758
5859 var string = '' ;
5960 for ( var chunk = 0 ; chunk < chunks ; chunk += 1 ) {
@@ -96,107 +97,107 @@ var _class = function () {
9697 function _class ( arg ) {
9798 ( 0 , _classCallCheck3 . default ) ( this , _class ) ;
9899
99- var charSet = void 0 ;
100+ var charset = void 0 ;
100101 if ( arg === undefined ) {
101- charSet = _charSet . charSet32 ;
102- } else if ( arg instanceof _charSet2 . default ) {
103- charSet = arg ;
102+ charset = charset32 ;
103+ } else if ( arg instanceof CharSet ) {
104+ charset = arg ;
104105 } else if ( typeof arg === 'string' || arg instanceof String ) {
105- charSet = new _charSet2 . default ( arg ) ;
106+ charset = new CharSet ( arg ) ;
106107 } else {
107108 throw new Error ( 'Invalid arg: must be either valid CharSet or valid chars' ) ;
108109 }
109110 var hideProps = {
110- charSet : charSet
111+ charset : charset
111112 } ;
112113 propMap . set ( this , hideProps ) ;
113114 }
114115
115116 ( 0 , _createClass3 . default ) ( _class , [ {
116117 key : 'smallID' ,
117118 value : function smallID ( ) {
118- var charSet = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charSet ;
119+ var charset = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charset ;
119120
120- return this . string ( 29 , charSet ) ;
121+ return this . string ( 29 , charset ) ;
121122 }
122123 } , {
123124 key : 'mediumID' ,
124125 value : function mediumID ( ) {
125- var charSet = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charSet ;
126+ var charset = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charset ;
126127
127- return this . string ( 69 , charSet ) ;
128+ return this . string ( 69 , charset ) ;
128129 }
129130 } , {
130131 key : 'largeID' ,
131132 value : function largeID ( ) {
132- var charSet = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charSet ;
133+ var charset = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charset ;
133134
134- return this . string ( 99 , charSet ) ;
135+ return this . string ( 99 , charset ) ;
135136 }
136137 } , {
137138 key : 'sessionID' ,
138139 value : function sessionID ( ) {
139- var charSet = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charSet ;
140+ var charset = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charset ;
140141
141- return this . string ( 128 , charSet ) ;
142+ return this . string ( 128 , charset ) ;
142143 }
143144 } , {
144145 key : 'token' ,
145146 value : function token ( ) {
146- var charSet = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charSet ;
147+ var charset = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : propMap . get ( this ) . charset ;
147148
148- return this . string ( 256 , charSet ) ;
149+ return this . string ( 256 , charset ) ;
149150 }
150151 } , {
151152 key : 'string' ,
152153 value : function string ( entropyBits ) {
153- var charSet = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : propMap . get ( this ) . charSet ;
154+ var charset = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : propMap . get ( this ) . charset ;
154155
155- var bytesNeeded = charSet . bytesNeeded ( entropyBits ) ;
156- return this . stringWithBytes ( entropyBits , cryptoBytes ( bytesNeeded ) , charSet ) ;
156+ var bytesNeeded = charset . bytesNeeded ( entropyBits ) ;
157+ return this . stringWithBytes ( entropyBits , cryptoBytes ( bytesNeeded ) , charset ) ;
157158 }
158159 } , {
159160 key : 'stringRandom' ,
160161 value : function stringRandom ( entropyBits ) {
161- var charSet = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : propMap . get ( this ) . charSet ;
162+ var charset = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : propMap . get ( this ) . charset ;
162163
163- var bytesNeeded = charSet . bytesNeeded ( entropyBits ) ;
164- return this . stringWithBytes ( entropyBits , randomBytes ( bytesNeeded ) , charSet ) ;
164+ var bytesNeeded = charset . bytesNeeded ( entropyBits ) ;
165+ return this . stringWithBytes ( entropyBits , randomBytes ( bytesNeeded ) , charset ) ;
165166 }
166167 } , {
167168 key : 'stringWithBytes' ,
168169 value : function stringWithBytes ( entropyBits , bytes ) {
169- var charSet = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : propMap . get ( this ) . charSet ;
170+ var charset = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : propMap . get ( this ) . charset ;
170171
171- return _stringWithBytes ( entropyBits , bytes , charSet ) ;
172+ return _stringWithBytes ( entropyBits , bytes , charset ) ;
172173 }
173174 } , {
174175 key : 'bytesNeeded' ,
175176 value : function bytesNeeded ( entropyBits ) {
176- var charSet = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : propMap . get ( this ) . charSet ;
177+ var charset = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : propMap . get ( this ) . charset ;
177178
178- return charSet . bytesNeeded ( entropyBits ) ;
179+ return charset . bytesNeeded ( entropyBits ) ;
179180 }
180181 } , {
181182 key : 'chars' ,
182183 value : function chars ( ) {
183- return propMap . get ( this ) . charSet . chars ( ) ;
184+ return propMap . get ( this ) . charset . chars ( ) ;
184185 }
185186 } , {
186187 key : 'use' ,
187- value : function use ( charSet ) {
188- if ( ! ( charSet instanceof _charSet2 . default ) ) {
188+ value : function use ( charset ) {
189+ if ( ! ( charset instanceof CharSet ) ) {
189190 throw new Error ( 'Invalid CharSet' ) ;
190191 }
191- propMap . get ( this ) . charSet = charSet ;
192+ propMap . get ( this ) . charset = charset ;
192193 }
193194 } , {
194195 key : 'useChars' ,
195196 value : function useChars ( chars ) {
196197 if ( ! ( typeof chars === 'string' || chars instanceof String ) ) {
197198 throw new Error ( 'Invalid chars: Must be string' ) ;
198199 }
199- this . use ( new _charSet2 . default ( chars ) ) ;
200+ this . use ( new CharSet ( chars ) ) ;
200201 }
201202 } ] ) ;
202203 return _class ;
0 commit comments