cleanup PMTiles constructor; metadata returns Promise

This commit is contained in:
Brandon Liu
2021-04-30 18:21:26 +08:00
parent 91792fd750
commit 41dda77cbd

View File

@@ -35,7 +35,7 @@ const bytesToMap = dataview => {
} }
export class PMTiles { export class PMTiles {
constructor(url, options = {}) { constructor(url) {
this.url = url this.url = url
const controller = new AbortController() const controller = new AbortController()
const signal = controller.signal const signal = controller.signal
@@ -60,8 +60,10 @@ export class PMTiles {
} }
metadata = func => { metadata = func => {
this.root.then(root => { return new Promise((resolve,reject) => {
func(root.metadata) this.root.then(root => {
resolve(root.metadata)
})
}) })
} }