mirror of
https://github.com/ipfs/awesome-ipfs.git
synced 2024-11-20 11:28:35 -05:00
a89015da98
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
28 lines
458 B
JavaScript
28 lines
458 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(/-+$/, '')
|
|
|
|
module.exports = {
|
|
sort,
|
|
sortInv,
|
|
sortAbc,
|
|
slugify
|
|
}
|