From f36b40cdec6ed4d87a0f21267a044ff3db60f033 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 26 Sep 2018 03:22:22 +0300 Subject: [PATCH] fix part 2, now AT(..) sees all the attributes that exist... Signed-off-by: Alex A. Naanou --- diff.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/diff.js b/diff.js index d67d1c6..afc8539 100644 --- a/diff.js +++ b/diff.js @@ -58,6 +58,24 @@ var MIN_TEXT_LENGTH = 100 //--------------------------------------------------------------------- // Helpers... +// getAllKeys(obj) +// -> Set([key, ..]) +// +// This is different to Object.keys(..) in that it gets both enumerable +// and non-enumerable keys as well as keys defined in prototypes... +var getAllKeys = function(obj){ + var res = new Set() + while(obj.__proto__ || obj === obj.__proto__){ + Object.getOwnPropertyNames(obj) + .forEach(function(n){ + res.add(n) + }) + obj = obj.__proto__ + } + return res +} + + // zip(array, array, ...) // -> [[item, item, ...], ...] //