Debian Codegraph @

lib/utils/objects.js

raw symbols SCIP
1 "use strict";
2
3 /* Object utilities. */
4 var objects = {
5 keys: function(object) {
6 var result = [], key;
7
8 for (key in object) {
9 if (object.hasOwnProperty(key)) {
10 result.push(key);
11 }
12 }
13
14 return result;
15 },
16
17 values: function(object) {
18 var result = [], key;
19
20 for (key in object) {
21 if (object.hasOwnProperty(key)) {
22 result.push(object[key]);
23 }
24 }
25
26 return result;
27 },
28
29 clone: function(object) {
30 var result = {}, key;
31
32 for (key in object) {
33 if (object.hasOwnProperty(key)) {
34 result[key] = object[key];
35 }
36 }
37
38 return result;
39 },
40
41 defaults: function(object, defaults) {
42 var key;
43
44 for (key in defaults) {
45 if (defaults.hasOwnProperty(key)) {
46 if (!(key in object)) {
47 object[key] = defaults[key];
48 }
49 }
50 }
51 }
52 };
53
54 module.exports = objects;