
var Observers = require("./observers");
var autoCancelPrevious = Observers.autoCancelPrevious;

exports.makePropertyBinder = makePropertyBinder;
function makePropertyBinder(observeObject, observeKey) {
    return function (observeValue, source, target, parameters) {
        return observeObject(autoCancelPrevious(function (object) {
            return observeKey(autoCancelPrevious(function (key) {
                return observeValue(autoCancelPrevious(function (value) {
                    object[key] = value;
                }), source, parameters);
            }), target, parameters);
        }), target, parameters);
    };
}

exports.makeHasBinder = makeHasBinder;
function makeHasBinder(observeSet, observeSought) {
    return function (observeValue, source, target, parameters) {
        return observeSet(autoCancelPrevious(function (set) {
            return observeSought(autoCancelPrevious(function (sought) {
                return observeValue(autoCancelPrevious(function (value) {
                    // wait for the initial value to be updated by the
                    // other-way binding
                    if (value === undefined) {
                    } else if (value) { // should be in set
                        if (!(set.has || set.contains).call(set, sought)) {
                            set.add(sought);
                        }
                    } else { // should not be in set
                        while ((set.has || set.contains).call(set, sought)) {
                            (set.remove || set['delete']).call(set, sought);
                        }
                    }
                }), target, parameters);
            }), source, parameters);
        }), source, parameters);
    };
}


@@ -712,22 +712,21 @@
  observe
-Sought
+Value
 ) %7B%0A    
@@ -741,37 +741,35 @@
 unction (observe
-Value
+Has
 , source, target
@@ -876,14 +876,13 @@
 erve
-Sought
+Value
 (aut
@@ -907,22 +907,21 @@
 nction (
-sought
+value
 ) %7B%0A    
@@ -938,37 +938,35 @@
   return observe
-Value
+Has
 (autoCancelPrevi
@@ -971,37 +971,35 @@
 vious(function (
-value
+has
 ) %7B%0A            
@@ -1122,21 +1122,19 @@
     if (
-value
+has
  === und
@@ -1174,21 +1174,19 @@
 lse if (
-value
+has
 ) %7B // s
@@ -1258,38 +1258,37 @@
 ains).call(set, 
-sought
+value
 )) %7B%0A           
@@ -1312,22 +1312,21 @@
 set.add(
-sought
+value
 );%0A     
@@ -1466,22 +1466,21 @@
 ll(set, 
-sought
+value
 )) %7B%0A   
@@ -1548,14 +1548,13 @@
 et, 
-sought
+value
 );%0A 

Readability of has binder