f0js
Advanced tools
Comparing version 0.0.18 to 0.0.19
26
index.js
@@ -14,2 +14,6 @@ const abi = require('./abi.js') | ||
if (options.cache) { | ||
this.cacheURL = options.cache | ||
} | ||
if (options.config) { | ||
@@ -198,3 +202,4 @@ this._config = options.config | ||
raw: rawConfig, | ||
converted: this.convert(rawConfig) | ||
converted: this.convert(rawConfig), | ||
cache: this.cache(rawConfig) | ||
} | ||
@@ -215,3 +220,4 @@ } | ||
raw: p, | ||
converted: this.convert(p) | ||
converted: this.convert(p), | ||
cache: this.cache(p) | ||
} | ||
@@ -318,6 +324,8 @@ } | ||
let converted = this.convert(r) | ||
let cached = this.cache(r) | ||
return { | ||
tokenURI: tokenURI, | ||
raw: r, | ||
converted: converted | ||
converted: converted, | ||
cache: cached | ||
} | ||
@@ -344,2 +352,14 @@ } | ||
} | ||
cache(raw) { | ||
if (this.cacheURL) { | ||
let r = JSON.parse(JSON.stringify(raw)) | ||
return traverse(r).map(function (x) { | ||
if (this.isLeaf && typeof x === 'string' && x.startsWith("ipfs://")) { | ||
this.update(this.cacheURL + x.replace("ipfs://", "")) | ||
} | ||
}) | ||
} else { | ||
return null | ||
} | ||
} | ||
async cost() { | ||
@@ -346,0 +366,0 @@ let [gas, price] = await Promise.all([ |
{ | ||
"name": "f0js", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,5 +23,6 @@ require('dotenv').config() | ||
image: 'https://ipfs.io/ipfs/bafybeihhl6qexxlf3x6jhhqfm2qdyrcctjrozx7nxfm5a7yo6ntgbajhea' | ||
} | ||
}, | ||
cache: null | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
4826681
1628