{"version":3,"file":"distributed.mjs","names":[],"sources":["../../../src/common/data/distributed.ts"],"sourcesContent":["/**\n * Distribute file, named by natural numbers, in a way that each folder only\n * contains `maxEntriesPerFolder` subfolders or files. Returns a list of\n * names, where the last one is the file name, all others are folder names.\n *\n * Example: `distributedFilePath(1003)` results in `['2', '1', '3']` which\n * could be translated to the file path `2/1/3.json`.\n */\nexport function distributedFilePath(index: number, maxEntriesPerFolder: number = 1000): string[] {\n  if (index < 0)\n    throw new Error('Only numbers >= 0 supported')\n  const names: string[] = []\n  do {\n    names.unshift((index % maxEntriesPerFolder).toString())\n    index = Math.floor(index / maxEntriesPerFolder)\n  } while (index > 0)\n  names.unshift(names.length.toString())\n  return names\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,oBAAoB,OAAe,sBAA8B,KAAgB;AAC/F,KAAI,QAAQ,EACV,OAAM,IAAI,MAAM,8BAA8B;CAChD,MAAM,QAAkB,EAAE;AAC1B,IAAG;AACD,QAAM,SAAS,QAAQ,qBAAqB,UAAU,CAAC;AACvD,UAAQ,KAAK,MAAM,QAAQ,oBAAoB;UACxC,QAAQ;AACjB,OAAM,QAAQ,MAAM,OAAO,UAAU,CAAC;AACtC,QAAO"}