Use kindof instead of typeof where appropriate.
This commit is contained in:
parent
c439daadad
commit
2071a7d308
@ -23,6 +23,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-runtime": "^5.6.11",
|
"babel-runtime": "^5.6.11",
|
||||||
|
"kindof": "^2.0.0",
|
||||||
"lodash.bind": "^3.1.0",
|
"lodash.bind": "^3.1.0",
|
||||||
"lodash.callback": "^3.3.0",
|
"lodash.callback": "^3.3.0",
|
||||||
"lodash.foreach": "^3.0.3",
|
"lodash.foreach": "^3.0.3",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import forEach from 'lodash.foreach'
|
import forEach from 'lodash.foreach'
|
||||||
|
import kindOf from 'kindof'
|
||||||
import {BaseError} from 'make-error'
|
import {BaseError} from 'make-error'
|
||||||
import {EventEmitter} from 'events'
|
import {EventEmitter} from 'events'
|
||||||
|
|
||||||
@ -33,13 +34,13 @@ export class DuplicateItem extends BaseError {
|
|||||||
|
|
||||||
export class IllegalTouch extends BaseError {
|
export class IllegalTouch extends BaseError {
|
||||||
constructor (value) {
|
constructor (value) {
|
||||||
super('only an object value can be touched (found a ' + typeof value + ')')
|
super('only an object value can be touched (found a ' + kindOf(value) + ')')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InvalidKey extends BaseError {
|
export class InvalidKey extends BaseError {
|
||||||
constructor (key) {
|
constructor (key) {
|
||||||
super('invalid key of type ' + typeof key)
|
super('invalid key of type ' + kindOf(key))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ export default class Collection extends EventEmitter {
|
|||||||
const [key] = this._resolveItem(keyOrObjectWithId)
|
const [key] = this._resolveItem(keyOrObjectWithId)
|
||||||
this._assertHas(key)
|
this._assertHas(key)
|
||||||
const value = this.get(key)
|
const value = this.get(key)
|
||||||
if (typeof value !== 'object' || value === null) {
|
if (kindOf(value) !== 'object') {
|
||||||
throw new IllegalTouch(value)
|
throw new IllegalTouch(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user