-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (37 loc) · 1.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const array={
createMultiDimensionNumArray:(rows,columns,startIndex=0,skip=1)=>{
let arr=Array.from({length:rows},()=>{
startValue=startIndex
startValue-=skip
return Array.from({length:columns},()=>{
startValue+=skip
return startValue;
})
})
return arr
},
createNumArray:(length,startIndex=0,skip=1)=>{
startIndex-=skip
let arr=Array.from({length:length},()=>{
startIndex+=skip
return startIndex;
})
return arr
},
createObjArray:(length,obj={})=>{
let arr=Array.from({length:length},()=>(obj))
return arr
},
createMultiDimensionObjArray:(rows,columns,obj={})=>{
let arr=Array.from({length:rows},()=>{
return Array.from({length:columns},()=>{
return obj;
})
})
return arr
},
createMap:(strArr=[])=>{
return new Map(strArr.entries());
}
}
module.exports = array;