MCPcopy Create free account
hub / github.com/pacexy/flow / load

Method load

packages/epubjs/src/section.js:49–79  ·  view source on GitHub ↗

* Load the section from its url * @param {method} [_request] a request method to use for loading * @return {document} a promise with the xml document

(_request)

Source from the content-addressed store, hash-verified

47 * @return {document} a promise with the xml document
48 */
49 load(_request) {
50 var request = _request || this.request || Request
51 var loading = new defer()
52 var loaded = loading.promise
53
54 if (this.contents) {
55 loading.resolve(this.contents)
56 } else {
57 request(this.url)
58 .then(
59 function (xml) {
60 // var directory = new Url(this.url).directory;
61
62 this.document = xml
63 this.contents = xml.documentElement
64
65 return this.hooks.content.trigger(this.document, this)
66 }.bind(this),
67 )
68 .then(
69 function () {
70 loading.resolve(this.contents)
71 }.bind(this),
72 )
73 .catch(function (error) {
74 loading.reject(error)
75 })
76 }
77
78 return loaded
79 }
80
81 /**
82 * Adds a base tag for resolving urls in the section

Callers 1

renderMethod · 0.95

Calls 3

requestFunction · 0.85
triggerMethod · 0.80
resolveMethod · 0.45

Tested by

no test coverage detected