Permalink
Browse files

Add Ember.computed.none… none + empty have different secants.

Also extract Ember.isNone into ember-metal
  • Loading branch information...
1 parent d232a68 commit 6195b498bb84dbcb89d657bfb0733d282cedca52 @stefanpenner stefanpenner committed Mar 7, 2013
View
12 packages/ember-metal/lib/computed.js
@@ -430,6 +430,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
@param {String} dependentKey
View
25 packages/ember-metal/lib/core.js
@@ -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.
View
0 ...s/ember-runtime/tests/core/isNone_test.js → ...es/ember-metal/tests/core/is_none_test.js
File renamed without changes.
View
23 packages/ember-runtime/lib/core.js
@@ -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:

2 comments on commit 6195b49

@stefanpenner
Ember.js member

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

@endash

I think it's the opposite of a cosine

Please sign in to comment.