@reldens/utils 0.19.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/shortcuts.js +22 -0
- package/package.json +1 -1
package/lib/shortcuts.js
CHANGED
|
@@ -302,6 +302,28 @@ class Shortcuts
|
|
|
302
302
|
return Number(Number(number).toFixed(decimals));
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
cleanMessage(message, characterLimit)
|
|
306
|
+
{
|
|
307
|
+
if(!message){
|
|
308
|
+
return '';
|
|
309
|
+
}
|
|
310
|
+
let text = message.toString().replace(/\\/g, '');
|
|
311
|
+
if(0 < characterLimit){
|
|
312
|
+
return text.substring(0, characterLimit);
|
|
313
|
+
}
|
|
314
|
+
return text;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
slugify(text)
|
|
318
|
+
{
|
|
319
|
+
return (text || '')
|
|
320
|
+
.replace(/&/g, ' and ')
|
|
321
|
+
.replace(/[^a-zA-Z0-9]/g, ' ')
|
|
322
|
+
.trim()
|
|
323
|
+
.replace(/\s+/g, '-')
|
|
324
|
+
.toLowerCase();
|
|
325
|
+
}
|
|
326
|
+
|
|
305
327
|
}
|
|
306
328
|
|
|
307
329
|
module.exports = new Shortcuts();
|