Example #1
0
QUnit.test("Ember.isBlank", function() {
  var string = "string";
  var fn = function() {};
  var object = { length: 0 };

  equal(true, isBlank(null), "for null");
  equal(true, isBlank(undefined), "for undefined");
  equal(true, isBlank(""), "for an empty String");
  equal(true, isBlank("  "), "for a whitespace String");
  equal(true, isBlank("\n\t"), "for another whitespace String");
  equal(false, isBlank("\n\t Hi"), "for a String with whitespaces");
  equal(false, isBlank(true), "for true");
  equal(false, isBlank(false), "for false");
  equal(false, isBlank(string), "for a String");
  equal(false, isBlank(fn), "for a Function");
  equal(false, isBlank(0), "for 0");
  equal(true, isBlank([]), "for an empty Array");
  equal(false, isBlank({}), "for an empty Object");
  equal(true, isBlank(object), "for an Object that has zero 'length'");
  equal(false, isBlank([1, 2, 3]), "for a non-empty array");
});
Example #2
0
/**
  A value is present if it not `isBlank`.

  ```javascript
  Ember.isPresent();                // false
  Ember.isPresent(null);            // false
  Ember.isPresent(undefined);       // false
  Ember.isPresent('');              // false
  Ember.isPresent([]);              // false
  Ember.isPresent('\n\t');          // false
  Ember.isPresent('  ');            // false
  Ember.isPresent({});              // true
  Ember.isPresent(false);           // true
  Ember.isPresent('\n\t Hello');    // true
  Ember.isPresent('Hello world');   // true
  Ember.isPresent([1,2,3]);         // true
  ```

  @method isPresent
  @for Ember
  @param {Object} obj Value to test
  @return {Boolean}
  @since 1.8.0
  @public
*/
export default function isPresent(obj) {
  return !isBlank(obj);
}