mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 18:40: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 =
|
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()))] }
|
||||||
|
|||||||
@ -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
21
test.js
@ -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']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user