Skip to content

Instantly share code, notes, and snippets.

@Hokid
Created June 1, 2018 18:26
Show Gist options
  • Save Hokid/9d7680bb78c7144ff70d86bc960be27e to your computer and use it in GitHub Desktop.
Save Hokid/9d7680bb78c7144ff70d86bc960be27e to your computer and use it in GitHub Desktop.
export function throwIfNotInstanse(instance, constructor) {
if (!(instance instanceof constructor)) {
throw new TypeError('object not instance of ' + constructor.name);
}
}
export function byId(list, id) {
return list.find((i) => i.id === id);
}
export function stripUnnecessaryZeros(number) {
return number.replace(/(\.0+|0+)$/, '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment