Extend supported json formats

Accept either a token metadata array (Token[]) or {token: Token[]}
This commit is contained in:
Mikko
2021-09-27 12:02:26 +03:00
committed by GitHub
parent 2479cdc7f4
commit 8d5e2b4076
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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) {