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.
- Host: GitHub
- URL: https://github.com/xotic750/to-object-x
- Owner: Xotic750
- License: mit
- Created: 2016-01-20T12:22:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T23:03:13.000Z (over 3 years ago)
- Last Synced: 2025-06-15T21:19:08.777Z (12 months ago)
- Topics: browser, ecmascript6, es6, nodejs
- Language: JavaScript
- Homepage:
- Size: 3.32 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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'))
```