lib/refs.js
function Refs(a, b) {

  if (!(this instanceof Refs)) {
    return new Refs(a, b);
  }

  // link
  a.inverse = b;
  b.inverse = a;

  this.props = {};
  this.props[a.name] = a;
  this.props[b.name] = b;
}
function Refs(a, b) {

  if (!(this instanceof Refs)) {
    return new Refs(a, b);
  }

  // link
  a.inverse = b;
  b.inverse = a;

  this.props = {};
  this.props[a.name] = a;
  this.props[b.name] = b;
}
function Refs ( a , b ) { if ( ! ( this instanceof Refs ) ) { return new Refs ( a , b ) ; } // link a . inverse = b ; b . inverse = a ; this . props = { } ; this . props [ a . name ] = a ; this . props [ b . name ] = b ; }
Creates a new references object defining two inversly related
attribute descriptors a and b.

<p>
When bound to an object using {@link Refs#bind} the references
get activated and ensure that add and remove operations are applied
reversely, too.
</p>

<p>
For attributes represented as collections {@link Refs} provides the
{@link RefsCollection#add}, {@link RefsCollection#remove} and {@link RefsCollection#contains} extensions
that must be used to properly hook into the inverse change mechanism.
</p>

@class Refs

@classdesc A bi-directional reference between two attributes.

@param {Refs.AttributeDescriptor} a property descriptor
@param {Refs.AttributeDescriptor} b property descriptor

@example

var refs = Refs({ name: 'wheels', collection: true, enumerable: true }, { name: 'car' });

var car = { name: 'toyota' };
var wheels = [{ pos: 'front-left' }, { pos: 'front-right' }];

refs.bind(car, 'wheels');

car.wheels // []
car.wheels.add(wheels[0]);
car.wheels.add(wheels[1]);

car.wheels // [{ pos: 'front-left' }, { pos: 'front-right' }]

wheels[0].car // { name: 'toyota' };
car.wheels.remove(wheels[0]);

wheels[0].car // undefined
Creates a new references object defining two inversly related attribute descriptors a and b .