File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 1
- 'use strict'
1
+ 'use strict' ;
2
2
function randomItemWithNoRepetition ( array ) {
3
- if ( ! Array . isArray ( array ) || array . length === 0 ) return - 1
4
- var copy = array . slice ( )
3
+ if ( ! Array . isArray ( array ) || array . length === 0 ) return - 1 ;
4
+ var copy = array . slice ( ) ;
5
5
return function ( ) {
6
- copy . length < 1 && ( copy = array . slice ( ) )
6
+ copy . length < 1 && ( copy = array . slice ( ) ) ;
7
7
var index = Math . floor ( Math . random ( ) * copy . length ) ,
8
- item = copy [ index ]
9
- return copy . splice ( index , 1 ) , item
8
+ item = copy [ index ] ;
9
+ return copy . splice ( index , 1 ) , item ;
10
10
}
11
11
}
12
12
13
- module . exports = randomItemWithNoRepetition
13
+ module . exports = randomItemWithNoRepetition ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @smakss/random-array-element" ,
3
- "version" : " 1.0.7 " ,
3
+ "version" : " 1.0.8 " ,
4
4
"description" : " Selects a random array element without repetition." ,
5
5
"type" : " module" ,
6
6
"main" : " ./index.cjs" ,
13
13
"url" : " git+https://github.com/SMAKSS/random-array-element.git"
14
14
},
15
15
"keywords" : [
16
- " ES5" ,
17
- " ES6" ,
18
16
" npm" ,
19
17
" yarn" ,
20
18
" array" ,
21
19
" SMAKSS" ,
22
20
" random" ,
21
+ " CommonJS" ,
22
+ " EcmaScript" ,
23
23
" random-index" ,
24
24
" random-array-element" ,
25
25
" random-element-without-repeat" ,
You can’t perform that action at this time.
0 commit comments