mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 02:20:08 +00:00
still broken, thinking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9da8b306d3
commit
89d2aa151c
@ -118,9 +118,10 @@ var deepKeys =
|
||||
module.deepKeys =
|
||||
function(obj, stop){
|
||||
var res = []
|
||||
while(obj!= null){
|
||||
while(obj != null){
|
||||
res.push(Object.keys(obj))
|
||||
obj = obj.__proto__
|
||||
// XXX need to stop but include the stop object...
|
||||
if(obj === stop){
|
||||
break }}
|
||||
return [...(new Set(res.flat()))] }
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-object",
|
||||
"version": "5.0.11",
|
||||
"version": "5.0.12",
|
||||
"description": "",
|
||||
"main": "object.js",
|
||||
"scripts": {
|
||||
|
||||
21
test.js
21
test.js
@ -589,6 +589,27 @@ module.cases = {
|
||||
assert.error('.parent(..) of anonymous function', 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']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user