import type Decimal from "break_infinity.js" ; import { Notation } from "../notation" ; import { ScientificNotation } from "../scientific" ; const scientific = new ScientificNotation ( ) ; const EMOJIER = [ "🎂" , "🎄" , "💀" , "👪" , "🌈" , "💯" , "🎃" , "💋" , "😂" , "🌙" ] ; export class EmojierNotation extends Notation { public get name ( ) : string { return "Emojier" ; } public formatUnder1000 ( value , places ) { return this . affect ( scientific . formatUnder1000 ( value , places ) ) ; } public formatDecimal ( value , places ) { return this . affect ( scientific . formatDecimal ( value , places ) ) ; } public affect ( formatted ) { const characters = formatted . split ( "" ) ; const seenDigits = [ ] ; for ( let i = 0 ; i < characters . length ; i ++ ) { if ( "0123456789" . includes ( characters [ i ] ) ) { if ( seenDigits . map ( ( x ) => x % 5 ) . includes ( Number ( characters [ i ] ) % 5 ) ) { const emojierIndex = seenDigits . map ( ( x ) => x % 5 ) . indexOf ( Number ( characters [ i ] ) % 5 ) + 5 * ( ( Number ( ! seenDigits . includes ( Number ( characters [ i ] ) ) ) + i ) % 2 ) ; characters [ i ] = EMOJIER [ emojierIndex ] ; } else { seenDigits . push ( Number ( characters [ i ] ) ) ; } } } return characters . join ( "" ) ; } }