https://github.com/chrisyip/node-object-class
Get object class string
https://github.com/chrisyip/node-object-class
nodejs nodejs-modules
Last synced: about 1 month ago
JSON representation
Get object class string
- Host: GitHub
- URL: https://github.com/chrisyip/node-object-class
- Owner: chrisyip
- License: mit
- Created: 2017-02-26T09:14:44.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-26T13:01:57.000Z (over 9 years ago)
- Last Synced: 2026-05-10T09:25:55.570Z (about 1 month ago)
- Topics: nodejs, nodejs-modules
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-object-class
[![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Travis CI][travis-image]][travis-url] [![codecov][codecov-image]](codecov-url)
Get object class string (e.g. `[object Object]`).
```js
import objClass from 'obj-class'
objClass({}) // [object Object]
objClass(Math) // [object Math]
objClass(async function () {}) // [object AsyncFunction]
class Foo {
get [Symbol.toStringTag] () {
return 'Foo'
}
}
objClass(new Foo) // [object Foo]
function func () {}
func[Symbol.toStringTag] = 'Func'
objClass(func) = '[object Func]'
objClass.nameOnly = true
objClass(Math) // Math
objClass(async function () {}) // AsyncFunction
```
Requires `node >= 4.0.0`.
[npm-url]: https://npmjs.org/package/obj-class
[npm-image]: http://img.shields.io/npm/v/obj-class.svg?style=flat-square
[daviddm-url]: https://david-dm.org/chrisyip/node-object-class
[daviddm-image]: http://img.shields.io/david/chrisyip/node-object-class.svg?style=flat-square
[travis-url]: https://travis-ci.org/chrisyip/node-object-class
[travis-image]: http://img.shields.io/travis/chrisyip/node-object-class.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/chrisyip/node-object-class
[codecov-image]: https://img.shields.io/codecov/c/github/chrisyip/node-object-class.svg?style=flat-square