Skip to content

Commit

Permalink
Bug Fixed: Can not wrap async functions returning null
Browse files Browse the repository at this point in the history
  • Loading branch information
keenondrums committed Apr 7, 2019
1 parent f5f4061 commit 9ef9972
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "class-logger",
"version": "1.0.1",
"version": "1.0.2",
"description": "Boilerplate-free decorator-based class logging",
"keywords": [
"decorator",
Expand Down
5 changes: 5 additions & 0 deletions src/class-wrapper.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ describe(ClassWrapperService.name, () => {
const isPromise = classWrapperService.isPromise({})
expect(isPromise).toBe(false)
})
test('returns false for null', () => {
const classWrapperService: any = new ClassWrapperService()
const isPromise = classWrapperService.isPromise(null)
expect(isPromise).toBe(false)
})
test('returns false for non-objects', () => {
const classWrapperService: any = new ClassWrapperService()
const isPromise = classWrapperService.isPromise('invalid')
Expand Down
2 changes: 1 addition & 1 deletion src/class-wrapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class ClassWrapperService {
}

protected isPromise(val: any) {
return typeof val === 'object' && typeof val.then === 'function' && typeof val.catch === 'function'
return !!val && typeof val === 'object' && typeof val.then === 'function' && typeof val.catch === 'function'
}

protected classGetConfigMerged(target: object) {
Expand Down

0 comments on commit 9ef9972

Please sign in to comment.