MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / Enumerator

Function Enumerator

libraries/p5.js:490–517  ·  view source on GitHub ↗
(Constructor, input)

Source from the content-addressed store, hash-verified

488}
489
490function Enumerator(Constructor, input) {
491 this._instanceConstructor = Constructor;
492 this.promise = new Constructor(noop);
493
494 if (!this.promise[PROMISE_ID]) {
495 makePromise(this.promise);
496 }
497
498 if (isArray(input)) {
499 this._input = input;
500 this.length = input.length;
501 this._remaining = input.length;
502
503 this._result = new Array(this.length);
504
505 if (this.length === 0) {
506 fulfill(this.promise, this._result);
507 } else {
508 this.length = this.length || 0;
509 this._enumerate();
510 if (this._remaining === 0) {
511 fulfill(this.promise, this._result);
512 }
513 }
514 } else {
515 _reject(this.promise, validationError());
516 }
517}
518
519function validationError() {
520 return new Error('Array Methods must be provided an Array');

Callers

nothing calls this directly

Calls 4

makePromiseFunction · 0.85
fulfillFunction · 0.85
_rejectFunction · 0.85
validationErrorFunction · 0.85

Tested by

no test coverage detected