Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.
function foo ({
bar = 'no',
baz = 'works!'
} = {}) {
#!/bin/bash | |
# This way you can customize which branches should be skipped when | |
# prepending commit message. | |
if [ -z "$BRANCHES_TO_SKIP" ]; then | |
BRANCHES_TO_SKIP=(master develop test) | |
fi | |
BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
BRANCH_NAME="${BRANCH_NAME##*/}" |
# Type(<scope>): <subject> | |
# <body> | |
# <footer> | |
# Type should be one of the following: | |
# * feat (new feature) | |
# * fix (bug fix) | |
# * docs (changes to documentation) |
function _get(property, defaultValue) { | |
var path = property.split(/[\.\["'\]]+/); | |
return function(obj) { | |
return typeof obj === 'object' ? path.reduce(function (acc, key) { | |
var value = acc && acc[key]; | |
// should allow null and falsy values. | |
return (value || (value !== undefined)) ? | |
value : | |
defaultValue; | |
}, obj) : |
//from https://github.com/achohq/acho/blob/0a57c8450e781ca69c248103f48a24818dca695b/lib/Constants.coffee | |
'use strict' | |
figure = | |
false: | |
info : 'ℹ' | |
success : '✔' | |
warning : '⚠' | |
error : '✖' |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
//remove the starting '?' and split options | |
location.search.slice(1).split("&").forEach(function(opt) { | |
opt = opt.split('='); | |
console.log(opt); // ['arg1','val1'] ['arg2','val2'] | |
}); |