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, ...], ...] //