From 2fcb8f986346e79dcc9bfd075f33e1301335a192 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 26 Jun 2021 03:27:17 +0300 Subject: [PATCH] experimenting... Signed-off-by: Alex A. Naanou --- diff2.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/diff2.js b/diff2.js index 1d35b45..d67b83f 100644 --- a/diff2.js +++ b/diff2.js @@ -405,10 +405,29 @@ module.WALK_HANDLERS = { return obj instanceof Map && obj.entries() } }, + /* XXX should we handle array elements differently??? + // ...these to simply mark attr type for the handler(..), not + // sure if the added complexity is worth it... (???) + array: { + walk: function(obj){ + return obj instanceof Array + && [...Object.entries(obj)] + .filter(function(e){ + return !isNaN(parseInt(e)) }) }}, + attr: { + walk: function(obj){ + return obj instanceof Array ? + [...Object.entries(obj)] + .filter(function(e){ + return isNaN(parseInt(e)) }) + : typeof(obj) == 'object' + && [...Object.entries(obj)] } }, + /*/ attr: { walk: function(obj){ return typeof(obj) == 'object' && [...Object.entries(obj)] } }, + //*/ proto: { walk: function(obj){ return typeof(obj) == 'object' @@ -431,6 +450,7 @@ module.WALK_HANDLERS = { // -> // !> STOP() // +// Link handling... // (, , , 'LINK') // -> // !> STOP()