Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Commit

Permalink
Use isPlainObject instead of isObject
Browse files Browse the repository at this point in the history
isObject returns true for Date, Buffer objects. This causes iterating into this objects, eventually, you lose the original Date and Buffer objects. Fixes mcmath#11
  • Loading branch information
ubenzer authored Aug 20, 2017
1 parent 45e5b63 commit 6f8f7b6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/deep-map.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import WeakMap = require('es6-weak-map');
import {isArray, isObject, isFunction, isNil} from 'lodash';
import {isArray, isPlainObject, isFunction, isNil} from 'lodash';

export interface DeepMapModule {
<T>(object: any, mapFn: MapFn, options?: Opts): T;
Expand All @@ -22,7 +22,7 @@ export const deepMapModule: DeepMapModule = function deepMap(object: any, mapFn:
throw new Error('mapFn is required');
} else if (!isFunction(mapFn)) {
throw new TypeError('mapFn must be a function');
} else if (!isObject(options)) {
} else if (!isPlainObject(options)) {
throw new TypeError('options must be an object');
}

Expand All @@ -42,7 +42,7 @@ class DeepMap {

public map(value: any, key?: string | number): any {
return isArray(value) ? this.mapArray(value) :
isObject(value) ? this.mapObject(value) :
isPlainObject(value) ? this.mapObject(value) :
this.mapFn.call(this.opts.thisArg, value, key);
}

Expand Down

0 comments on commit 6f8f7b6

Please sign in to comment.