diff --git a/packages/xo-collection/src/collection.js b/packages/xo-collection/src/collection.js index d404fce51..84388f2fc 100644 --- a/packages/xo-collection/src/collection.js +++ b/packages/xo-collection/src/collection.js @@ -4,6 +4,7 @@ import {BaseError} from 'make-error' import {EventEmitter} from 'events' import isEmpty from './is-empty' +import isObject from './is-object' // =================================================================== @@ -139,7 +140,7 @@ export default class Collection extends EventEmitter { const [key] = this._resolveItem(keyOrObjectWithId) this._assertHas(key) const value = this.get(key) - if (kindOf(value) !== 'object') { + if (!isObject(value)) { throw new IllegalTouch(value) } diff --git a/packages/xo-collection/src/is-object.js b/packages/xo-collection/src/is-object.js new file mode 100644 index 000000000..737694cb7 --- /dev/null +++ b/packages/xo-collection/src/is-object.js @@ -0,0 +1,3 @@ +export function isObject (value) { + return (value !== null) && (typeof value === 'object') +}