Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active April 5, 2023 18:37
Show Gist options
  • Save wilmoore/679ddecb2cdeb07418bd8fae295dc246 to your computer and use it in GitHub Desktop.
Save wilmoore/679ddecb2cdeb07418bd8fae295dc246 to your computer and use it in GitHub Desktop.
Income Sources :: uniqode :: spike

Income Sources :: uniqode :: spike

⪼ Made with 💜 by realpolyglot.com

ūniqöde

const uniqode = (start, end) => {
  const code = (hex) => parseInt(hex, 16);
  const logo = (hex) => String.fromCodePoint(code(hex));
  const ends = (hex) => code(hex) === code(end);
  const next = (hex) => (code(hex) + 1).toString(16);

  let curr = start;
  const out = [];

  while (!ends(curr)) {
    out.push([curr.toUpperCase(), logo(curr)]);
    out.push({
      code: code(curr),
      hex: curr,
      logo: logo(curr),
    })
    curr = next(curr).toUpperCase();
  }

  return out;
}

const HEX_RANGE = ['1F00', '1FFF'];
console.log(uniqode.apply(null, HEX_RANGE));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment