import { hashItem } from "../src/hash-item" ; import occurences from "../data/occurences.json" ; import { itemLevelFromOccurences } from "./utils" ; type Occurences = Record < string , number > ; async function main ( ) { const hashedItems = Object . entries ( occurences as Occurences ) . map ( ( [ name , occurences ] ) => [ hashItem ( name ) , occurences ] ) ; const uniques = new Set ( hashedItems . map ( ( [ hash ] ) => hash ) ) . size ; if ( hashedItems . length !== uniques ) { throw new Error ( "Collision! Please check src/hash-item.ts" ) ; } const byLevel = hashedItems . reduce ( ( byLevel , [ hash , occurences ] ) => { const level = itemLevelFromOccurences ( Number ( occurences ) ) ; if ( level === 1 ) { return byLevel ; } const index = level - 2 ; const levelHashes = byLevel [ index ] ?? "" ; byLevel [ index ] = levelHashes + hash ; return byLevel ; } , [ ] ) ; console . log ( JSON . stringify ( byLevel ) ) ; } main ( ) . then ( ( ) => { process . exit ( 0 ) ; } ) . catch ( ( err ) => { console . error ( err ) ; process . exit ( 1 ) ; } ) ;