mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:27:58 +01:00
Make :style better
This commit is contained in:
@@ -172,6 +172,20 @@ liberator.util = { //{{{
|
||||
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
},
|
||||
|
||||
escapeRegex: function (str)
|
||||
{
|
||||
return str.replace(/([\\{}()[\].?*+])/g, "\\$1");
|
||||
},
|
||||
|
||||
// Flatten an array:
|
||||
// [["foo", "bar"], ["baz"]] -> ["foo", "bar", "baz"]
|
||||
flatten: function (ary)
|
||||
{
|
||||
if (ary.length == 0)
|
||||
return [];
|
||||
return Array.concat.apply(Array, ary);
|
||||
},
|
||||
|
||||
formatBytes: function (num, decimalPlaces, humanReadable)
|
||||
{
|
||||
const unitVal = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
||||
@@ -416,6 +430,18 @@ liberator.util = { //{{{
|
||||
return urls;
|
||||
},
|
||||
|
||||
uniq: function (ary)
|
||||
{
|
||||
let ret = [];
|
||||
for (let [,item] in Iterator(ary.sort()))
|
||||
{
|
||||
if (item != last || !ret.length)
|
||||
ret.push(item);
|
||||
var last = item;
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
xmlToDom: function (node, doc)
|
||||
{
|
||||
switch (node.nodeKind())
|
||||
|
||||
Reference in New Issue
Block a user