forked from albertsun/JavaScript-Geometry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary.js
More file actions
56 lines (51 loc) · 1.37 KB
/
Copy pathdictionary.js
File metadata and controls
56 lines (51 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Author: Albert Sun
WSJ.com News Graphics
*/
/*jslint white: false, debug: false, devel: true, onevar: false, plusplus: false, browser: true, bitwise: false */
/*global jQuery: false, $: false, log: false, window: false */
// Necessary functions
if (!window.typeOf) {
window.typeOf = function(b){var a=typeof b;if(a==="object")if(b){if(b instanceof Array)a="array"}else a="null";return a};
}
var WSJNG = WSJNG || {};
// an object with some handy extensions
WSJNG.Dictionary = function() {
};
WSJNG.Dictionary.prototype = {
get length() {
var count = 0;
for (var prop in this) {
if (this.hasOwnProperty(prop)) {
count = count+1;
}
}
return count;
},
keys: function() {
var keys = [];
for (var prop in this) {
if (this.hasOwnProperty(prop)) {
keys.push(prop);
}
}
return keys;
},
values: function() {
var values = [];
for (var prop in this) {
if (this.hasOwnProperty(prop)) {
values.push(this[prop]);
}
}
return values;
},
items: function() {
var items = [];
for (var prop in this) {
if (this.hasOwnProperty(prop)) {
items.push([prop, this[prop]]);
}
}
return items;
}
};