lib/Sentinel.js
function Sentinel(label, propertiesObject) {
  if (!(this instanceof Sentinel)) {
    return new Sentinel(label, propertiesObject);
  }

  if (typeof label === 'object' && label) {
    propertiesObject = label;
    label = undefined;
  }

  if (typeof label === 'number') {
    label = String(label);
  } else if (typeof label !== 'undefined') {
    if (typeof label !== 'string' || !label) {
      throw new TypeError('Expected label to be a non-empty string or number.');
    }
  }

  Object.defineProperties(this, {
    _sentinel_id: {
      value: ++instanceCount,
      //enumerable to work with Chai's `deep-eql`.
      enumerable: true
    },

    _sentinel_label: {
      value: label
    }
  });

  if (propertiesObject) {
    Object.defineProperties(this, propertiesObject);
  }
}
function Sentinel(label, propertiesObject) {
  if (!(this instanceof Sentinel)) {
    return new Sentinel(label, propertiesObject);
  }

  if (typeof label === 'object' && label) {
    propertiesObject = label;
    label = undefined;
  }

  if (typeof label === 'number') {
    label = String(label);
  } else if (typeof label !== 'undefined') {
    if (typeof label !== 'string' || !label) {
      throw new TypeError('Expected label to be a non-empty string or number.');
    }
  }

  Object.defineProperties(this, {
    _sentinel_id: {
      value: ++instanceCount,
      //enumerable to work with Chai's `deep-eql`.
      enumerable: true
    },

    _sentinel_label: {
      value: label
    }
  });

  if (propertiesObject) {
    Object.defineProperties(this, propertiesObject);
  }
}
function Sentinel ( label , propertiesObject ) { if ( ! ( this instanceof Sentinel ) ) { return new Sentinel ( label , propertiesObject ) ; } if ( typeof label === 'object' && label ) { propertiesObject = label ; label = undefined ; } if ( typeof label === 'number' ) { label = String ( label ) ; } else if ( typeof label !== 'undefined' ) { if ( typeof label !== 'string' || ! label ) { throw new TypeError ( 'Expected label to be a non-empty string or number.' ) ; } } Object . defineProperties ( this , { _sentinel_id : { value : ++ instanceCount , //enumerable to work with Chai's `deep-eql`. enumerable : true } , _sentinel_label : { value : label } } ) ; if ( propertiesObject ) { Object . defineProperties ( this , propertiesObject ) ; } }
If truey, `propertiesObject` is used to define properties on the sentinel instance. Can be used without `new`.
If truey propertiesObject is used to define properties on the sentinel instance . Can be used without new .