File size: 609 Bytes
e192d16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"use strict";

const utils = require("../utils");

module.exports = function (defaultFuncs, api, ctx) {
	return function addExternalModule(moduleObj) {
		if (utils.getType(moduleObj) == "Object") {
			for (const apiName in moduleObj) {
				if (utils.getType(moduleObj[apiName]) == "Function") {
					api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
				} else {
					throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
				}
			}
		} else {
			throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
		}
  }
	};