UNPKG

@adonisjs/fold

Version:

Dependency manager and IoC container for your next NodeJs application

38 lines (37 loc) 1.13 kB
"use strict"; /* * @adonisjs/fold * * (c) Harminder Virk <virk@adonisjs.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ensureIsFunction = exports.isPrimtiveConstructor = exports.isEsm = void 0; const utils_1 = require("@poppinss/utils"); /** * Returns a boolean telling if value is an esm module * with `export default`. */ function isEsm(value) { return value && value.__esModule; } exports.isEsm = isEsm; /** * Returns a boolean telling if value is a primitive or object constructor. */ function isPrimtiveConstructor(value) { return [String, Function, Object, Date, Number, Boolean].indexOf(value) > -1; } exports.isPrimtiveConstructor = isPrimtiveConstructor; /** * Raises error with a message when callback is not * a function. */ function ensureIsFunction(callback, message) { if (typeof callback !== 'function') { throw new utils_1.Exception(message, 500, 'E_RUNTIME_EXCEPTION'); } } exports.ensureIsFunction = ensureIsFunction;