/** * @file ES6-compliant shim for ToObject. * @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-toobject|7.1.13 ToObject ( argument )} * @version 1.5.0 * @author Xotic750 * @copyright Xotic750 * @license {@link MIT} * @module to-object-x */ 'use strict'; var requireObjectCoercible = require('require-object-coercible-x'); var castObject = require('cached-constructors-x').Object; /** * The abstract operation ToObject converts argument to a value of * type Object. * * @param {*} value - The `value` to convert. * @throws {TypeError} If `value` is a `null` or `undefined`. * @returns {!Object} The `value` converted to an object. * @example * var ToObject = require('to-object-x'); * * ToObject(); // TypeError * ToObject(null); // TypeError * ToObject('abc'); // Object('abc') * ToObject(true); // Object(true) * ToObject(Symbol('foo')); // Object(Symbol('foo')) */ module.exports = function toObject(value) { return castObject(requireObjectCoercible(value)); };