Skip to content

Instantly share code, notes, and snippets.

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@nickbanderson
nickbanderson / global.js
Created August 26, 2021 15:05
custom switch functions added to Object prototype
Object.defineProperty(Object.prototype, 'switchExpr', {
value: function(selection, planB) {
if (selection in this)
return this[selection];
// (REMOVE?) if an array of booleans is passed, try to shortcircuit
if (/^(true|false),((true|false),?)*$/.test(selection)) {
let shrinkingStr = selection.join(',');
while (shrinkingStr.includes(',')) {
shrinkingStr = shrinkingStr.substr(0, shrinkingStr.lastIndexOf(','));