From aa0d6ca19db1f1d9c985bbd06706ba8baf8f9e3b Mon Sep 17 00:00:00 2001 From: Akim McMath Date: Wed, 15 Jun 2016 18:34:54 -0700 Subject: [PATCH] Fix: for...in loop `for...in` loop should iterate over own enumerable properties only. --- src/deep-map-keys.ts | 6 ++++-- tslint.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/deep-map-keys.ts b/src/deep-map-keys.ts index b0f6d93..73a2b6b 100644 --- a/src/deep-map-keys.ts +++ b/src/deep-map-keys.ts @@ -43,8 +43,10 @@ function mapObject(obj: {[key: string]: any}, fn: MapFn, opts: Options): {[key: let result: {[key: string]: any} = {}; for (let key in obj) { - let value = obj[key]; - result[fn.call(opts.thisArg, key, value)] = map(value, fn, opts); + if (obj.hasOwnProperty(key)) { + let value = obj[key]; + result[fn.call(opts.thisArg, key, value)] = map(value, fn, opts); + } } return result; diff --git a/tslint.json b/tslint.json index a01a39f..a1cba23 100644 --- a/tslint.json +++ b/tslint.json @@ -23,7 +23,7 @@ }], "ban": false, "curly": false, - "forin": false, + "forin": true, "label-position": true, "no-arg": true, "no-bitwise": false,