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 abbreviatedNumber(value: number, precision=2): string { | |
if (isNaN(value)) { | |
return ""; | |
} | |
let newValue = value; | |
const suffixes = ["", "K", "M", "B", "T"]; | |
let suffixNum = 0; | |
while (Math.abs(newValue) >= 1000) { | |
newValue /= 1000; | |
suffixNum++; |
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
#!/usr/bin/env node | |
// Takes an rgba() CSS value and converts it to its 8 digit hexadecimal value. | |
// | |
// Usage: ./rgbaToHex.js "{YOUR_RGBA_STRING}" | |
// | |
// Example: ./rgbaToHex.js "rgba(197, 200, 198, .2)" => #C5C8C633 | |
function trim (str) { | |
return str.replace(/^\s+|\s+$/gm,''); |