mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-31 15:19:42 +02:00
Update:Remove node-cron dependency
This commit is contained in:
parent
26ef275ab4
commit
b7e546f2f5
19 changed files with 686 additions and 18 deletions
39
server/libs/nodeCron/convert-expression/range-conversion.js
Normal file
39
server/libs/nodeCron/convert-expression/range-conversion.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
module.exports = ( () => {
|
||||
function replaceWithRange(expression, text, init, end) {
|
||||
|
||||
const numbers = [];
|
||||
let last = parseInt(end);
|
||||
let first = parseInt(init);
|
||||
|
||||
if(first > last){
|
||||
last = parseInt(init);
|
||||
first = parseInt(end);
|
||||
}
|
||||
|
||||
for(let i = first; i <= last; i++) {
|
||||
numbers.push(i);
|
||||
}
|
||||
|
||||
return expression.replace(new RegExp(text, 'i'), numbers.join());
|
||||
}
|
||||
|
||||
function convertRange(expression){
|
||||
const rangeRegEx = /(\d+)-(\d+)/;
|
||||
let match = rangeRegEx.exec(expression);
|
||||
while(match !== null && match.length > 0){
|
||||
expression = replaceWithRange(expression, match[0], match[1], match[2]);
|
||||
match = rangeRegEx.exec(expression);
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
function convertAllRanges(expressions){
|
||||
for(let i = 0; i < expressions.length; i++){
|
||||
expressions[i] = convertRange(expressions[i]);
|
||||
}
|
||||
return expressions;
|
||||
}
|
||||
|
||||
return convertAllRanges;
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue