An open API service indexing awesome lists of open source software.

https://github.com/xotic750/to-object-x

ES6-compliant shim for ToObject.
https://github.com/xotic750/to-object-x

browser ecmascript6 es6 nodejs

Last synced: 9 months ago
JSON representation

ES6-compliant shim for ToObject.

Awesome Lists containing this project

README

          


Travis status


Dependency status


devDependency status


npm version


jsDelivr hits


bettercodehub score


Coverage Status

## to-object-x

ES6-compliant shim for ToObject.

**See**: [7.1.13 ToObject ( argument )](http://www.ecma-international.org/ecma-262/6.0/#sec-toobject)

### `module.exports(value)` ⇒ Object

The abstract operation ToObject converts argument to a value of
type Object.

**Kind**: Exported function
**Returns**: Object - The `value` converted to an object.
**Throws**:

- TypeError If `value` is a `null` or `undefined`.

| Param | Type | Description |
| ----- | --------------- | ----------------------- |
| value | \* | The `value` to convert. |

**Example**

```js
import toObject from 'to-object-x';

toObject(); // TypeError
toObject(null); // TypeError
console.log(toObject('abc')); // Object('abc')
console.log(toObject(true)); // Object(true)
console.log(toObject(Symbol('foo'))); // Object(Symbol('foo'))
```