Skip to content

Commit

Permalink
Add Ember.computed.none… none + empty have different secants.
Browse files Browse the repository at this point in the history
Also extract Ember.isNone into ember-metal
  • Loading branch information
stefanpenner committed Mar 7, 2013
1 parent d232a68 commit 6195b49
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
12 changes: 12 additions & 0 deletions packages/ember-metal/lib/computed.js
Expand Up @@ -429,6 +429,18 @@ Ember.computed.not = function(dependentKey) {
});
};

/**
@method computed.none
@for Ember
@param {String} dependentKey
*/
Ember.computed.none = function(dependentKey) {
return Ember.computed(dependentKey, function(key) {
var val = get(this, dependentKey);
return Ember.isNone(val);
});
};

/**
@method computed.empty
@for Ember
Expand Down
25 changes: 25 additions & 0 deletions packages/ember-metal/lib/core.js
Expand Up @@ -228,6 +228,31 @@ Ember.merge = function(original, updates) {
original[prop] = updates[prop];
}
};

/**
Returns true if the passed value is null or undefined. This avoids errors
from JSLint complaining about use of ==, which can be technically
confusing.
```javascript
Ember.isNone(); // true
Ember.isNone(null); // true
Ember.isNone(undefined); // true
Ember.isNone(''); // false
Ember.isNone([]); // false
Ember.isNone(function(){}); // false
```
@method isNone
@for Ember
@param {Object} obj Value to test
@return {Boolean}
*/
Ember.isNone = function(obj) {
return obj === null || obj === undefined;
};
Ember.none = Ember.deprecateFunc("Ember.none is deprecated. Please use Ember.isNone instead.", Ember.isNone);

/**
Verifies that a value is `null` or an empty string, empty array,
or empty function.
Expand Down
23 changes: 0 additions & 23 deletions packages/ember-runtime/lib/core.js
Expand Up @@ -83,29 +83,6 @@ Ember.typeOf = function(item) {
};

/**
Returns true if the passed value is null or undefined. This avoids errors
from JSLint complaining about use of ==, which can be technically
confusing.
```javascript
Ember.isNone(); // true
Ember.isNone(null); // true
Ember.isNone(undefined); // true
Ember.isNone(''); // false
Ember.isNone([]); // false
Ember.isNone(function(){}); // false
```
@method isNone
@for Ember
@param {Object} obj Value to test
@return {Boolean}
*/
Ember.isNone = function(obj) {
return obj === null || obj === undefined;
};
Ember.none = Ember.deprecateFunc("Ember.none is deprecated. Please use Ember.isNone instead.", Ember.isNone);

This will compare two javascript values of possibly different types.
It will tell you which one is greater than the other by returning:
Expand Down

2 comments on commit 6195b49

@stefanpenner
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wtf is a secant... scumbag stef should read this commits...

@endash
Copy link
Contributor

@endash endash commented on 6195b49 Mar 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's the opposite of a cosine

Please sign in to comment.