brando
Advanced tools
Comparing version 0.0.55 to 0.0.56
@@ -59,3 +59,3 @@ /* | ||
fp.on( 'fart', function ( result, ratio ) { | ||
log( '\n- FULLPERM(%d), SHUFFLE(%d)',fp.items, 4 - runs,'(Fisher-Yates with random source).' ); | ||
log( '\n- FULLPERM(%d), SHUFFLE(%d)', fp.items, 4 - runs,'(Fisher-Yates with random source).' ); | ||
log( ' :fart:', fp.result ); | ||
@@ -62,0 +62,0 @@ log( '- random values used: %d%\n', ( 100 * ratio ).toFixed( 2 ) ); |
@@ -82,5 +82,4 @@ /* | ||
* it ensures that the algorithm converges quickly. | ||
* Otherwise it could run indefinitively, consuming a lot of random data, also to | ||
* produce only a short-size full range permutation. | ||
* The bad aspect: it will probably produce more biased results. | ||
* Otherwise it could run indefinitively, consuming a lot of random data, only to | ||
* produce a short-length full range permutation. | ||
*/ | ||
@@ -87,0 +86,0 @@ fproto.parse = function ( data ) { |
@@ -81,7 +81,6 @@ /* | ||
* about 1/8 the memory consumption; then PP should never be used with a set of | ||
* values that covers no more than ~7/8 of the full range, to avoid waste of memory, | ||
* in this case it is better to use FP. | ||
* values that covers more than ~7/8 of the full range, to avoid waste of memory, | ||
* in those cases it is better to use FP. | ||
* | ||
* How many bytes of random data will be consumed, depends on the ratio between items | ||
* and the range selected. | ||
* How many bytes of random data will be consumed, depends on the range selected. | ||
* | ||
@@ -88,0 +87,0 @@ * Generally the minimum consumption of data happens when we have range equal to a power of 2, |
@@ -36,4 +36,4 @@ /* | ||
/* | ||
* Get how many bits and bytes are necessary to* represent values in the | ||
* specified range, minimum value is 1 byte. | ||
* Get how many bits and bytes are necessary to represent | ||
* values in the specified range, minimum size is 1 byte. | ||
*/ | ||
@@ -40,0 +40,0 @@ me.range = r >>> 0 ? abs( r ) : 1; |
{ | ||
"name": "brando" | ||
, "version": "0.0.55" | ||
, "version": "0.0.56" | ||
, "description": "Brando." | ||
@@ -5,0 +5,0 @@ , "homepage": "https://github.com/rootslab/brando" |
@@ -68,9 +68,10 @@ ### Brando | ||
> A simple factory method, it returns an EventEmitter that parses random data and emits results | ||
> with the number of selected items and within the selected range. Internally, it creates an empty | ||
> Buffer of the length necessary to hold all requested values. It is possible to fill it with values | ||
> generated through Math.Random (biased result) or through a random source of data. | ||
> If repetition is off, it returns a _[Sequence](lib/filters/emitters/sequence)_, otherwise a | ||
> sub-type of Sequence; when items value is equal to range, it returns a _[FullPerm](lib/filters/emitters/fullperm)_, | ||
> otherwise a _[PartPerm](lib/filters/emitters/partperm)_. | ||
> with the number of selected items and within the selected range (__unsigned integers__). Internally, | ||
> it creates an empty Buffer of the length necessary to hold all requested values, thent is possible | ||
> to fill it with values generated through Math.Random (biased result) or through a random source | ||
> of data. | ||
> __NOTE:__ If repetition is off, it returns a _[Sequence](lib/filters/emitters/sequence)_, otherwise a | ||
> sub-type of Sequence; when items value is equal to range, it returns a _[FullPerm](lib/filters/emitters/fullperm)_, otherwise a _[PartPerm](lib/filters/emitters/partperm)_. | ||
```javascript | ||
@@ -92,7 +93,7 @@ /* | ||
* | ||
* - for executing multiple times a (trivial) Fisher-Yates shuffle, after #fill or #parse. | ||
* - for executing multiple times a Fisher-Yates shuffle (using Math.random) | ||
* | ||
* Sequence#shuffle : function ( [ Number times ] ) : Sequence | ||
* | ||
* - for resetting internal status and result buffer, before reusing it: | ||
* - before reusing Sequence, resetting internal status and/or set a new result buffer: | ||
* | ||
@@ -105,3 +106,3 @@ * Sequence#clear : function ( [ Boolean trash [, Boolean refill ] ] ) : Sequence | ||
* | ||
* - using #parse, it emits: | ||
* - using #parse, Sequence emits: | ||
* - 'feed' when needs more data: function ( Number miss_bytes, Number curr_usage_ratio ) | ||
@@ -108,0 +109,0 @@ * - 'fart' when result is ready: function ( Buffer result, Number curr_usage_ratio ) |
183
76848
1178