still broken, thinking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-06-14 17:54:01 +03:00
parent 9da8b306d3
commit 89d2aa151c
3 changed files with 24 additions and 2 deletions

View File

@ -118,9 +118,10 @@ var deepKeys =
module.deepKeys = module.deepKeys =
function(obj, stop){ function(obj, stop){
var res = [] var res = []
while(obj!= null){ while(obj != null){
res.push(Object.keys(obj)) res.push(Object.keys(obj))
obj = obj.__proto__ obj = obj.__proto__
// XXX need to stop but include the stop object...
if(obj === stop){ if(obj === stop){
break }} break }}
return [...(new Set(res.flat()))] } return [...(new Set(res.flat()))] }

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-object", "name": "ig-object",
"version": "5.0.11", "version": "5.0.12",
"description": "", "description": "",
"main": "object.js", "main": "object.js",
"scripts": { "scripts": {

21
test.js
View File

@ -589,6 +589,27 @@ module.cases = {
assert.error('.parent(..) of anonymous function', function(){ assert.error('.parent(..) of anonymous function', function(){
object.parent(function(){}, {}) }) object.parent(function(){}, {}) })
}, },
'deepKeys': function(assert){
var a = {
a: true
}
var b = {
__proto__: a,
b: true,
}
var c = {
__proto__: b,
c: true,
}
assert(arrayCmp(object.deepKeys(c), ['a', 'b', 'c']), 'full')
assert(arrayCmp(object.deepKeys(c, a), ['a', 'b', 'c']), 'full 2')
// XXX these are wrong...
console.log('>>>>', object.deepKeys(c, a)) // -/-> ['a', 'b', 'c']
console.log('>>>>', object.deepKeys(c, b)) // -/-> ['b', 'c']
console.log('>>>>', object.deepKeys(c, c)) // -/-> ['c']
}
} }