/** * @file ES6-compliant shim for RequireObjectCoercible. * @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-requireobjectcoercible|7.2.1 RequireObjectCoercible ( argument )} * @version 1.4.1 * @author Xotic750 * @copyright Xotic750 * @license {@link MIT} * @module require-object-coercible-x */ 'use strict'; var isNil = require('is-nil-x'); /** * The abstract operation RequireObjectCoercible throws an error if argument * is a value that cannot be converted to an Object using ToObject. * * @param {*} value - The `value` to check. * @throws {TypeError} If `value` is a `null` or `undefined`. * @returns {string} The `value`. * @example * var RequireObjectCoercible = require('require-object-coercible-x'); * * RequireObjectCoercible(); // TypeError * RequireObjectCoercible(null); // TypeError * RequireObjectCoercible('abc'); // 'abc' * RequireObjectCoercible(true); // true * RequireObjectCoercible(Symbol('foo')); // Symbol('foo') */ module.exports = function RequireObjectCoercible(value) { if (isNil(value)) { throw new TypeError('Cannot call method on ' + value); } return value; };