[RandomStorage] Adds random storage in jio
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved

Owner
@xiaowu.zhang @vincentB is this storage used in the media player?
What do you think of reviewing it?

Developer
this storage is not used

src/jio.storage/randomstorage.js 0 → 100644
45 if (options.sort_on[0][0] === 'random') { 46 limit = options.limit; 47 delete options.limit; 48 } 49 return this._sub_storage.buildQuery.apply(this._sub_storage, 50 arguments) 51 .push(function (result) { 52 // Random shuffle the result when random is present in the options. 53 if (options.sort_on[0][0] === 'random') { 54 var final_result = [], 55 random_number; 56 57 while (limit[1] && result.length  limit[0]) { 58 random_number = Math.floor(Math.random() * result.length); 59 random_number = random_number === result.length ? 60 result.length  1 : random_number; 
Developer
this check is useless, Math.random() return a floatingpoint, pseudorandom number in the range 0–1 (inclusive of 0, but not 1), so random_number is always < result.length


test/jio.storage/randomstorage.tests.js 0 → 100644
477 id: 'v16', 478 value: 'man445' 479 }, { 480 id: 'v17', 481 value: 'hhf45' 482 }, { 483 id: 'v18', 484 value: 'hg45' 485 }, { 486 id: 'v19', 487 value: 'foo34' 488 }, { 489 id: 'v20', 490 value: 'man20' 491 }]); 492 }) 
Developer
test is not complete, it doesn't test the following case:
 limit[0] > item length, for example: limit = [21,5], but the result has only 20 items.
 limit[0] < item length : limit[12,5],and result has 20 items
 limit[0] < item length, but limit[1] > item length: limit[12, 23] and result has 20 item
