This file contains 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
export class Dispatcher { | |
constructor () { | |
this.events = {}; | |
} | |
addListener (event, callback) { | |
// Check if the callback is not a function | |
if (typeof callback !== 'function') { | |
console.error(`The listener callback must be a function, the given type is ${typeof callback}`); | |
return false; |
This file contains 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
export function renameKeyName(obj, oldName, newName) { | |
const clone = cloneDeep(obj); | |
const keyVal = clone[oldName]; | |
delete clone[oldName]; | |
clone[newName] = keyVal; | |
return clone; | |
} |
This file contains 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
h scroll left | |
j scroll down | |
k scroll up | |
l scroll right | |
gg scroll to top of the page | |
G scroll to bottom of the page | |
f activate link hints mode to open in current tab | |
F activate link hints mode to open in new tab | |
r reload |
This file contains 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
import isObject from 'lodash/fp/isObject'; | |
import isBoolean from 'lodash/fp/isBoolean'; | |
// this is a naive implementation | |
export function validateData(data, rules) { | |
let errors = {}; | |
const isValid = Object.keys(rules).reduce((_isValid, key) { | |
const error = validateField(data[key], rules[key]); | |