This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Package Control.last-run | |
Package Control.ca-list | |
Package Control.ca-bundle | |
Package Control.system-ca-bundle | |
Package Control.cache/ | |
Package Control.ca-certs/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
ae = !"$(git ed) \"$(git ad)$1.gitalias\" #" # edit a given .gitalias file (or main one) | |
al = !"afs=($(git afs)) && for n in \"${!afs[@]}\"; do echo \"$n - ${afs[$n]}\"; done && read n && trap 'return' SIGINT && $(git ed) ${afs[$n]} #" # list all .gitalias files + choose one to edit | |
af = !"git config --global --get-all include.path | grep "/.gitalias" #" # pq grep -l ".gitalias" $(git config --global --get-all include.path) funciona? | |
afs = !"git config --global --get-all include.path #" | |
ad = !"echo $(git af) | head -c-10" | |
alias-sync = !"git -C \"$(git ad)\" pull origin master && git -C \"$(git ad)\" push origin master #" | |
alias = ae | |
as = !"git alias-sync #" | |
au = !"git -C \"$(git ad)\" ac \"$1\" && git as #" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Escape JSON | |
*/ | |
var escapeJSON = exports.escapeJSON = function(json) { | |
var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | |
var meta = { // table of character substitutions | |
'\b': '\\b', | |
'\t': '\\t', | |
'\n': '\\n', | |
'\f': '\\f', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function objFilter (obj, filter, nonstrict) { | |
const r = {} | |
if (!filter) return r | |
if (typeof filter == 'string') return {[filter]: obj[filter]} | |
for (const p in obj) { | |
if (typeof filter == 'object' && nonstrict && obj[p] == filter[p]) r[p] = obj[p] | |
else if (typeof filter == 'object' && !nonstrict && obj[p] === filter[p]) r[p] = obj[p] | |
else if (typeof filter == 'function') if (filter(obj[p], p, obj)) r[p] = obj[p] | |
else if (filter.length && filter.includes(p)) r[p] = obj[p] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function forInDeep(obj,cbBefore,cbAfter) { | |
var key; | |
for (key in obj) { | |
if (cbBefore) cbBefore(obj[key],key,obj) | |
if (typeof obj[key] == 'object') forInDeep(obj[key], cbBefore, cbAfter) | |
if (cbAfter) cbAfter(obj[key],key,obj) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reduceRev(array, cb, result) { | |
var length = array? array.length : 0; | |
while (length--) { | |
result = cb(result, array[length], length, array); | |
} | |
return result; | |
} |
Usage:
set(obj, 'a.b.c.d.e', value)
||set(obj, [a, 'b', '@#$', 'd', 'e'], [1, 2, 3])
||set(arr, '0.1.2', true)
- For bracket notation (e.g. obj['@#$']), use arrays
- Creates arrays with numbered keys (numbers not allowed as objects keys, see other revisions for that)
Explanation
function set (
obj, // object in which to set nested properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get (obj, path, def) { | |
return (path.split && path.split('.') || path).reduce((o, p) => ((o || obj)[p] ?? def), 0) | |
} |
NewerOlder