Skip to content

Commit

Permalink
simpler type
Browse files Browse the repository at this point in the history
  • Loading branch information
0xADADA authored and 0xADADA committed Nov 24, 2019
1 parent 1953c19 commit 8b3d616
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
interface NamedCharRange {
emoticons: string;
food: string;
animals: string;
expressions: string;
}
type NamedCharRange = 'emoticons' | 'food' | 'animals' | 'expressions';

const CHAR_RANGE = {
emoticons: [0x1f600, 0x1f64f],
Expand All @@ -12,7 +7,7 @@ const CHAR_RANGE = {
expressions: [0x1f910, 0x1f92f]
};

const random = function(range: keyof NamedCharRange = 'emoticons'): string {
const random = function(range: NamedCharRange = 'emoticons'): string {
const [max, min] = CHAR_RANGE[range];
const codePoint = Math.floor(Math.random() * (max - min) + min);
return String.fromCodePoint(codePoint);
Expand Down

0 comments on commit 8b3d616

Please sign in to comment.