import { get } from './property_get';
import isNone from './is_none';

/**
  Verifies that a value is `null` or an empty string, empty array,
  or empty function.

  Constrains the rules on `Ember.isNone` by returning true for empty
  string and empty arrays.

  ```javascript
  Ember.isEmpty();                // true
  Ember.isEmpty(null);            // true
  Ember.isEmpty(undefined);       // true
  Ember.isEmpty('');              // true
  Ember.isEmpty([]);              // true
  Ember.isEmpty({});              // false
  Ember.isEmpty('Adam Hawkins');  // false
  Ember.isEmpty([0,1,2]);         // false
  Ember.isEmpty('\n\t');          // false
  Ember.isEmpty('  ');            // false
  ```

  @method isEmpty
  @for Ember
  @param {Object} obj Value to test
  @return {Boolean}
  @public
*/
export default function isEmpty(obj) {
  let none = isNone(obj);
  if (none) {
    return none;
  }

  if (typeof obj.size === 'number') {
    return !obj.size;
  }

  let objectType = typeof obj;

  if (objectType === 'object') {
    let size = get(obj, 'size');
    if (typeof size === 'number') {
      return !size;
    }
  }

  if (typeof obj.length === 'number' && objectType !== 'function') {
    return !obj.length;
  }

  if (objectType === 'object') {
    let length = get(obj, 'length');
    if (typeof length === 'number') {
      return !length;
    }
  }

  return false;
}

@@ -104,16 +104,29 @@
 null%60 or
+ %60undefined%60,
  an empt
@@ -138,41 +138,28 @@
 ing,
+ or an
  empty
+%0A 
  array
-,%0A  or empty function
 .%0A%0A 
@@ -229,21 +229,22 @@
 mpty
-%0A 
  string
+s
  and
+%0A 
  emp

Improve Ember.isEmpty