mirror of
https://github.com/jwinterm/rarity-analyser.git
synced 2026-10-17 05:41:40 +02:00
Extend supported json formats
Accept either a token metadata array (Token[]) or {token: Token[]}
This commit is contained in:
+2
-2
@@ -47,9 +47,9 @@ type Counts = {
|
||||
* @returns Collection with rarity data
|
||||
*/
|
||||
export const analyse = (
|
||||
t: Array<Record<string, string | number | Attribute[]>>
|
||||
c: Array<Record<string, string | number | Attribute[]>> | { tokens: Array<Record<string, string | number | Attribute[]>> }
|
||||
): Collection => {
|
||||
const tokens: Token[] = preprocess(t)
|
||||
const tokens: Token[] = preprocess('tokens' in c ? c.tokens : c)
|
||||
const n = tokens.length
|
||||
let traitTypes = getTraitTypeSet(tokens)
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ const argv = yargs(process.argv.slice(2)).options({
|
||||
if ('json' in argv) {
|
||||
console.log('Analysing data...')
|
||||
const rawData = readFileSync(argv.json, { encoding: 'utf-8' })
|
||||
const tokens: Token[] = JSON.parse(rawData)
|
||||
const tokens: Token[] | { tokens: Token[] } = JSON.parse(rawData)
|
||||
const collection = analyse(tokens)
|
||||
|
||||
if (argv.saveJson) {
|
||||
|
||||
Reference in New Issue
Block a user