in Ox.extend, use Ox.slice; add includePrototype argument to Ox.methods
This commit is contained in:
parent
f83d317407
commit
75558d4b9d
1 changed files with 12 additions and 3 deletions
|
@ -6,7 +6,7 @@ Ox.extend <function> Extends an object with one or more other objects
|
||||||
{a: 1, b: 2, c: 3}
|
{a: 1, b: 2, c: 3}
|
||||||
@*/
|
@*/
|
||||||
Ox.extend = function(obj) {
|
Ox.extend = function(obj) {
|
||||||
Ox.forEach(Array.prototype.slice.call(arguments, 1), function(arg, i) {
|
Ox.forEach(Ox.slice(arguments, 1), function(arg, i) {
|
||||||
Ox.forEach(arg, function(val, key) {
|
Ox.forEach(arg, function(val, key) {
|
||||||
obj[key] = val;
|
obj[key] = val;
|
||||||
});
|
});
|
||||||
|
@ -39,8 +39,17 @@ Ox.methods <f> Returns a sorted list of all method names of an object
|
||||||
> Ox.methods({a: [], b: false, f: function() {}, n: 0, o: {}, s: ''})
|
> Ox.methods({a: [], b: false, f: function() {}, n: 0, o: {}, s: ''})
|
||||||
['f']
|
['f']
|
||||||
@*/
|
@*/
|
||||||
Ox.methods = function(obj) {
|
Ox.methods = function(obj, includePrototype) {
|
||||||
return Object.keys(obj).filter(function(key) {
|
var key, keys;
|
||||||
|
if (includePrototype) {
|
||||||
|
keys = [];
|
||||||
|
for (var key in obj) {
|
||||||
|
keys.push(key);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
keys = Object.keys(obj);
|
||||||
|
}
|
||||||
|
return keys.filter(function(key) {
|
||||||
return Ox.isFunction(obj[key]);
|
return Ox.isFunction(obj[key]);
|
||||||
}).sort();
|
}).sort();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue