https://github.com/chrisyip/co-debug
Better debug information for co
https://github.com/chrisyip/co-debug
Last synced: 12 months ago
JSON representation
Better debug information for co
- Host: GitHub
- URL: https://github.com/chrisyip/co-debug
- Owner: chrisyip
- License: mit
- Created: 2017-04-08T19:18:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-09T09:50:47.000Z (about 9 years ago)
- Last Synced: 2025-06-22T13:48:06.133Z (12 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# co-debug
[](https://github.com/chrisyip/co-debug) [![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Travis CI][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url]
Better debug information for co.
`co-debug` turns
```
TypeError: You may only yield a function, promise, generator, array, or object, but the following object was passed: "undefined"
at next (co-debug/node_modules/co/index.js:101:25)
...
```
into
```
TypeError: You may only yield a function, promise, generator, array, or object, but the following object was passed: "undefined"
co-debug/test/test.js function: foo
0: yield bar()
1: yield Promise.resolve()
at next (co-debug/node_modules/co/index.js:101:25)
...
```
## Install
```
npm i co-debug
```
You may need to install `co` by yourself.
## Usage
```
node -r co-debug
```
Or add `require('co-debug')` to your main file and make sure it's loaded before other packages:
```js
require('co-debug')
const Koa = require('koa')
const app = new Koa()
app.use(function * () {})
```
## Notes
### `co-debug` has some limitations
`co-debug` only can tell:
- The function name that throws error
- The list of `yield` within the function
- The file path that contains the function
Examples:
```
co-debug/test/test.js function: foo
0: yield bar()
1: yield Promise.resolve()
```
`co-debug` may have trouble working with transpilers.
### Only use `co-debug` when needed
```js
if (process.env.NODE_ENV !== 'production') {
require('co-debug')
}
const co = require('co')
// other stuffs
```
[npm-url]: https://npmjs.org/package/co-debug
[npm-image]: http://img.shields.io/npm/v/co-debug.svg
[daviddm-url]: https://david-dm.org/chrisyip/co-debug
[daviddm-image]: http://img.shields.io/david/chrisyip/co-debug.svg
[travis-url]: https://travis-ci.org/chrisyip/co-debug
[travis-image]: http://img.shields.io/travis/chrisyip/co-debug.svg
[codecov-url]: https://codecov.io/gh/chrisyip/co-debug
[codecov-image]: https://img.shields.io/codecov/c/github/chrisyip/co-debug.svg