mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-16 12:45:49 +02:00
40 lines
647 B
JavaScript
40 lines
647 B
JavaScript
/**
|
|
* String utilities
|
|
*/
|
|
|
|
export default {
|
|
|
|
lower(text){
|
|
return text.toLowerCase();
|
|
},
|
|
|
|
upper(text){
|
|
return text.toUpperCase();
|
|
},
|
|
|
|
trim(text){
|
|
if (text.trim){
|
|
return text.trim();
|
|
}
|
|
return text.replace(/^\s*|\s*$/g, '');
|
|
},
|
|
|
|
isEmpty(text){
|
|
return this.trim(text) === '';
|
|
},
|
|
|
|
rgxEsc(text){
|
|
let chars = /[-\/\\^$*+?.()|[\]{}]/g;
|
|
let escMatch = '\\$&';
|
|
return String(text).replace(chars, escMatch);
|
|
},
|
|
|
|
matchCase(text, mc){
|
|
if(!mc){
|
|
return this.lower(text);
|
|
}
|
|
return text;
|
|
}
|
|
|
|
};
|