UNPKG

774 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const lodash_1 = require("./wrap/lodash");
4const function_1 = require("./function");
5const imitate_1 = require("./imitate");
6exports.default = (typeOrNames) => lodash_1.default.isFunction(typeOrNames)
7 ? imitate_1.default(typeOrNames)
8 : fakeConstructorFromNames(typeOrNames);
9var fakeConstructorFromNames = (funcNames) => {
10 return lodash_1.default.tap(function_1.default('(unnamed constructor)'), (fakeConstructor) => {
11 fakeConstructor.prototype.toString = () => '[test double instance of constructor]';
12 lodash_1.default.each(funcNames, (funcName) => {
13 fakeConstructor.prototype[funcName] = function_1.default(`#${String(funcName)}`);
14 });
15 });
16};