Utility functions cleanup: Cleanup lib/utils/objects.js

redux
David Majda 10 years ago
parent 50b2054fbf
commit 1582304f16

@ -1,37 +1,45 @@
/* Object utilities. */ /* Object utilities. */
var objects = { var objects = {
keys: function(object) { keys: function(object) {
var result = []; var result = [], key;
for (var key in object) {
for (key in object) {
if (object.hasOwnProperty(key)) { if (object.hasOwnProperty(key)) {
result.push(key); result.push(key);
} }
} }
return result; return result;
}, },
values: function(object) { values: function(object) {
var result = []; var result = [], key;
for (var key in object) {
for (key in object) {
if (object.hasOwnProperty(key)) { if (object.hasOwnProperty(key)) {
result.push(object[key]); result.push(object[key]);
} }
} }
return result; return result;
}, },
clone: function(object) { clone: function(object) {
var result = {}; var result = {}, key;
for (var key in object) {
for (key in object) {
if (object.hasOwnProperty(key)) { if (object.hasOwnProperty(key)) {
result[key] = object[key]; result[key] = object[key];
} }
} }
return result; return result;
}, },
defaults: function(object, defaults) { defaults: function(object, defaults) {
for (var key in defaults) { var key;
for (key in defaults) {
if (defaults.hasOwnProperty(key)) { if (defaults.hasOwnProperty(key)) {
if (!(key in object)) { if (!(key in object)) {
object[key] = defaults[key]; object[key] = defaults[key];

Loading…
Cancel
Save