mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 18:40:08 +00:00
moving to generators...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c3cbd26a62
commit
dcb1321e6a
51
object.js
51
object.js
@ -427,7 +427,6 @@ BOOTSTRAP(function(){
|
|||||||
// this...
|
// this...
|
||||||
//
|
//
|
||||||
// XXX user doc!!!
|
// XXX user doc!!!
|
||||||
// XXX should we use this for sources(..) and friends...
|
|
||||||
var stoppable =
|
var stoppable =
|
||||||
module.stoppable =
|
module.stoppable =
|
||||||
function(func){
|
function(func){
|
||||||
@ -761,24 +760,22 @@ function(proto, name){
|
|||||||
if(name == ''){
|
if(name == ''){
|
||||||
throw new Error('parent(..): need a method with non-empty .name') }
|
throw new Error('parent(..): need a method with non-empty .name') }
|
||||||
// get first matching source...
|
// get first matching source...
|
||||||
proto = sources(that, name,
|
var i = 0
|
||||||
function(obj, i){
|
for(var obj of _sources(that, name)){
|
||||||
// NOTE: the .hasOwnProperty(..) test is here so as
|
// NOTE: the .hasOwnProperty(..) test is here so as
|
||||||
// to skip the base callable when searching for
|
// to skip the base callable when searching for
|
||||||
// .__call__ that is returned as a special case
|
// .__call__ that is returned as a special case
|
||||||
// by sourcei(..) and this should have no effect
|
// by source(..) and this should have no effect
|
||||||
// or other cases...
|
// or other cases...
|
||||||
// NOTE: this will only skip the root callable...
|
// NOTE: this will only skip the root callable...
|
||||||
return (i > 0 || obj.hasOwnProperty(name))
|
if((i++ > 0 || obj.hasOwnProperty(name))
|
||||||
&& obj[name] === proto
|
&& obj[name] === proto){
|
||||||
&& module.STOP })
|
proto = obj
|
||||||
.pop() }
|
break }}}
|
||||||
// get first source...
|
// get first source...
|
||||||
var res = sources(proto, name,
|
var res = _sources(proto, name)
|
||||||
function(obj, i){
|
res.next()
|
||||||
return i == 1
|
res = res.next().value
|
||||||
&& module.STOP })
|
|
||||||
.pop()
|
|
||||||
return !res ?
|
return !res ?
|
||||||
undefined
|
undefined
|
||||||
:(!(name in res) && typeof(res) == 'function') ?
|
:(!(name in res) && typeof(res) == 'function') ?
|
||||||
@ -797,11 +794,9 @@ var parentProperty =
|
|||||||
module.parentProperty =
|
module.parentProperty =
|
||||||
function(proto, name){
|
function(proto, name){
|
||||||
// get second source...
|
// get second source...
|
||||||
var res = sources(proto, name,
|
var res = _sources(proto, name)
|
||||||
function(obj, i){
|
res.next()
|
||||||
return i == 1
|
res = res.next().value
|
||||||
&& module.STOP })
|
|
||||||
.pop()
|
|
||||||
return res ?
|
return res ?
|
||||||
// get next value...
|
// get next value...
|
||||||
Object.getOwnPropertyDescriptor(res, name)
|
Object.getOwnPropertyDescriptor(res, name)
|
||||||
@ -847,7 +842,7 @@ function(proto, name, that, ...args){
|
|||||||
var parentOf =
|
var parentOf =
|
||||||
module.parentOf =
|
module.parentOf =
|
||||||
function(parent, child){
|
function(parent, child){
|
||||||
return new Set(sources(child)).has(parent) }
|
return new Set([..._sources(child)]).has(parent) }
|
||||||
|
|
||||||
// Reverse of parentOf(..)
|
// Reverse of parentOf(..)
|
||||||
var childOf =
|
var childOf =
|
||||||
@ -1500,11 +1495,9 @@ function(base, object){
|
|||||||
mixins(base, object, function(){ return module.STOP })
|
mixins(base, object, function(){ return module.STOP })
|
||||||
.length > 0
|
.length > 0
|
||||||
// flat mixin search...
|
// flat mixin search...
|
||||||
|| sources(base, function(p){
|
|| [..._sources(base)]
|
||||||
return matchPartial(p, object) ?
|
.some(function(p){
|
||||||
module.STOP
|
return matchPartial(p, object) }) )}
|
||||||
: [] })
|
|
||||||
.length > 0 )}
|
|
||||||
|
|
||||||
|
|
||||||
// Mix-out sets of methods/props/attrs out of an object prototype chain...
|
// Mix-out sets of methods/props/attrs out of an object prototype chain...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user