mirror of
https://github.com/ipfs/awesome-ipfs.git
synced 2024-12-18 04:04:18 -05:00
32 lines
566 B
JavaScript
32 lines
566 B
JavaScript
|
const sort = (a, b) => {
|
||
|
if (a < b) return -1
|
||
|
if (a > b) return 1
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
const sortInv = (a, b) => -sort(a, b)
|
||
|
|
||
|
const sortAbc = (a, b) => {
|
||
|
a = a.toLowerCase()
|
||
|
b = b.toLowerCase()
|
||
|
return sort(a, b)
|
||
|
}
|
||
|
|
||
|
const slugify = (text) => text.toString()
|
||
|
.toLowerCase()
|
||
|
.replace(/\s+/g, '-')
|
||
|
.replace(/[^\w-]+/g, '')
|
||
|
.replace(/--+/g, '-')
|
||
|
.replace(/^-+/, '')
|
||
|
.replace(/-+$/, '')
|
||
|
|
||
|
const capitalize = (text) => `${text.charAt(0).toUpperCase()}${text.slice(1).toLowerCase()}`
|
||
|
|
||
|
module.exports = {
|
||
|
sort,
|
||
|
sortInv,
|
||
|
sortAbc,
|
||
|
slugify,
|
||
|
capitalize
|
||
|
}
|