| 123456789101112131415161718192021222324252627282930313233343536373839 |
- let library ={
- formatSeconds(value) {
- let result = parseInt(value);
- // let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
- // let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
- let m = Math.floor((result / 60 % 60)) < 10 ? '' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
- let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
- let res = '';
- // if(h !== '00') res += `${h}h`;
- // if(m !== '00') res += `${m}min`;
- // res += `${s}s`;
- // if(h !== '00') res += `${h}:`;
- res += `${m}:`;
- res += `${s}`;
- return res;
- },
- randomInt(min, max){
- return Math.floor(Math.random() * (max - min)) + min;
- },
- removeObj(arr,obj)
- {
- let index = this.indexOf(arr,obj);
- if (index > -1) {
- arr.splice(index, 1);
- }
- },
- indexOf(arr,obj) {
- for (var i = 0; i < arr.length; i++) {
- if (arr[i] == obj) return i;
- }
- return -1;
- },
- insert(arr,index, item) {
- arr.splice(index, 0, item);
- },
- };
- module.exports = library;
|