- const result = objectCreate(getPrototype(loadMethods));
- const methodKeys = getOwnPropertyKeys(loadMethods);
- for (let index = 0; index < methodKeys.length; ++index) {
- const methodKey = methodKeys[index];
- const { configurable, enumerable, writable } =
- getOwnPropertyDescriptor(loadMethods, methodKey);
- defineOwnProperty(result, methodKey, {
- configurable: true,
- enumerable,
- get: () => {
- const value = call(loadMethods[methodKey], result, []);
- defineOwnProperty(result, methodKey, {
- configurable,
- enumerable,
- value,
- writable,
- });
- return value;
- },
- set: writable
- ? ($) =>
+ if (type(loadMethods) !== "object") {
+ throw new TypeError(
+ `Piscēs: Cannot construct LazyLoader: Provided argument is not an object: ${loadMethods}.`,
+ );
+ } else {
+ const result = objectCreate(getPrototype(loadMethods));
+ const methodKeys = getOwnPropertyKeys(loadMethods);
+ for (let index = 0; index < methodKeys.length; ++index) {
+ const methodKey = methodKeys[index];
+ const { configurable, enumerable, writable } =
+ getOwnPropertyDescriptor(loadMethods, methodKey);
+ defineOwnProperty(result, methodKey, {
+ configurable: true,
+ enumerable,
+ get: () => {
+ const value = call(loadMethods[methodKey], result, []);