MCPcopy Create free account
hub / github.com/TruthHun/BookStack / generateHolderClass

Function generateHolderClass

static/word2md/mammoth.browser.js:6235–6301  ·  view source on GitHub ↗
(total)

Source from the content-addressed store, hash-verified

6233 };
6234
6235 var generateHolderClass = function(total) {
6236 var props = new Array(total);
6237 for (var i = 0; i < props.length; ++i) {
6238 props[i] = "this.p" + (i+1);
6239 }
6240 var assignment = props.join(" = ") + " = null;";
6241 var cancellationCode= "var promise;\n" + props.map(function(prop) {
6242 return " \n\
6243 promise = " + prop + "; \n\
6244 if (promise instanceof Promise) { \n\
6245 promise.cancel(); \n\
6246 } \n\
6247 ";
6248 }).join("\n");
6249 var passedArguments = props.join(", ");
6250 var name = "Holder$" + total;
6251
6252
6253 var code = "return function(tryCatch, errorObj, Promise, async) { \n\
6254 'use strict'; \n\
6255 function [TheName](fn) { \n\
6256 [TheProperties] \n\
6257 this.fn = fn; \n\
6258 this.asyncNeeded = true; \n\
6259 this.now = 0; \n\
6260 } \n\
6261 \n\
6262 [TheName].prototype._callFunction = function(promise) { \n\
6263 promise._pushContext(); \n\
6264 var ret = tryCatch(this.fn)([ThePassedArguments]); \n\
6265 promise._popContext(); \n\
6266 if (ret === errorObj) { \n\
6267 promise._rejectCallback(ret.e, false); \n\
6268 } else { \n\
6269 promise._resolveCallback(ret); \n\
6270 } \n\
6271 }; \n\
6272 \n\
6273 [TheName].prototype.checkFulfillment = function(promise) { \n\
6274 var now = ++this.now; \n\
6275 if (now === [TheTotal]) { \n\
6276 if (this.asyncNeeded) { \n\
6277 async.invoke(this._callFunction, this, promise); \n\
6278 } else { \n\
6279 this._callFunction(promise); \n\
6280 } \n\
6281 \n\
6282 } \n\
6283 }; \n\
6284 \n\
6285 [TheName].prototype._resultCancelled = function() { \n\
6286 [CancellationCode] \n\
6287 }; \n\
6288 \n\
6289 return [TheName]; \n\
6290 }(tryCatch, errorObj, Promise, async); \n\
6291 ";
6292

Callers 1

mammoth.browser.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected