brando
Advanced tools
Comparing version 0.0.48 to 0.0.49
@@ -14,7 +14,7 @@ var log = console.log | ||
, onFeed = function ( bytes, used_ratio ) { | ||
log( ' :feed, need other %d bytes, used: %d%', bytes, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( ' :feed, need other %d bytes, consumed: %d%', bytes, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
} | ||
, onFart = function ( result, used_ratio ) { | ||
etime = Date.now(); | ||
log( ' :fart %d bytes, used: %d%', result.length, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( ' :fart %d bytes, consumed: %d%', result.length, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( '- parsed result in: %d s\n', ( etime - stime ) / 1000 ); | ||
@@ -21,0 +21,0 @@ } |
@@ -15,7 +15,7 @@ var log = console.log | ||
, onFeed = function ( bytes, used_ratio ) { | ||
log( ' :feed, need other %d bytes, used: %d%', bytes, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( ' :feed, need other %d bytes, consumed: %d%', bytes, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
} | ||
, onFart = function ( result, used_ratio ) { | ||
etime = Date.now(); | ||
log( ' :fart %d bytes, used: %d%', result.length, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( ' :fart %d bytes, consumed: %d%', result.length, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( '- parsed result in: %d s\n', ( etime - stime ) / 1000 ); | ||
@@ -22,0 +22,0 @@ } |
@@ -16,7 +16,7 @@ var log = console.log | ||
, onFeed = function ( bytes, used_ratio ) { | ||
log( ' :feed, need other %d bytes, used: %d%', bytes, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( ' :feed, need other %d bytes, consumed: %d%', bytes, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
} | ||
, onFart = function ( result, used_ratio ) { | ||
etime = Date.now(); | ||
log( ' :fart %d bytes, used: %d%', result.length, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( ' :fart %d bytes, consumed: %d%', result.length, ( used_ratio * 100 ).toFixed( 2 ) ); | ||
log( '- parsed result in: %d s\n', ( etime - stime ) / 1000 ); | ||
@@ -23,0 +23,0 @@ } |
@@ -103,2 +103,3 @@ /* | ||
, wbits = -1 | ||
, ratio = -1 | ||
; | ||
@@ -116,5 +117,6 @@ for ( ; me.wpos; o += ibytes ) { | ||
} | ||
ratio = tbytes < o ? tbytes / o : 1; | ||
return me.wpos ? | ||
me.emit( 'feed', me.wpos, tbytes / o ) : | ||
me.emit( 'fart', me.result, tbytes / o ) | ||
me.emit( 'feed', me.wpos, ratio ) : | ||
me.emit( 'fart', me.result, ratio ) | ||
; | ||
@@ -121,0 +123,0 @@ }; |
@@ -128,2 +128,3 @@ /* | ||
, o = 0 | ||
, ratio = -1 | ||
; | ||
@@ -138,5 +139,6 @@ for ( ; me.wpos < tbytes; o += ibytes ) { | ||
} | ||
ratio = tbytes < o ? tbytes / o : 1; | ||
return me.wpos < tbytes ? | ||
me.emit( 'feed', tbytes - me.wpos, tbytes / o ) : | ||
me.emit( 'fart', me.result, tbytes / o ) | ||
me.emit( 'feed', tbytes - me.wpos, ratio ) : | ||
me.emit( 'fart', me.result, ratio ) | ||
; | ||
@@ -143,0 +145,0 @@ }; |
@@ -69,2 +69,4 @@ /* | ||
; | ||
// create new Buffer | ||
me.result = new Buffer( me.tbytes ); | ||
// clear result buffer and indexes | ||
@@ -163,2 +165,3 @@ if ( zerofill ) me.result.fill(); | ||
, s = 0 | ||
, ratio = -1 | ||
; | ||
@@ -185,5 +188,6 @@ for ( ; me.wpos < tbytes; o += ibytes ) { | ||
} | ||
ratio = tbytes < o ? tbytes / o : 1; | ||
return me.wpos < tbytes ? | ||
me.emit( 'feed', tbytes - me.wpos, tbytes / o ) : | ||
me.emit( 'fart', me.result, tbytes / o ) | ||
me.emit( 'feed', tbytes - me.wpos, ratio ) : | ||
me.emit( 'fart', me.result, ratio ) | ||
; | ||
@@ -190,0 +194,0 @@ }; |
{ | ||
"name": "brando" | ||
, "version": "0.0.48" | ||
, "version": "0.0.49" | ||
, "description": "Brando." | ||
@@ -5,0 +5,0 @@ , "homepage": "https://github.com/rootslab/brando" |
@@ -89,3 +89,3 @@ ### Brando | ||
* | ||
* - for resetting internal status: | ||
* - for resetting internal status and result buffer, before reusing it: | ||
* | ||
@@ -99,4 +99,4 @@ * Sequence#clear : function ( [ Boolean zerofill ] ) : Sequence | ||
* - using #parse, it emits: | ||
* - 'feed' when it needs more random data. | ||
* - 'fart' when result is ready. | ||
* - 'feed' when needs more data: function ( Number miss_bytes, Number curr_usage_ratio ) | ||
* - 'fart' when result is ready: function ( Number missing_bytes, Buffer result, Number curr_usage_ratio ) | ||
*/ | ||
@@ -103,0 +103,0 @@ Brando#get : function ( Number items, Number range [, Number repeat ] ) : Sequence |
74184
27
1129
7