forked from elavoie/photon-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdlib.js
93 lines (84 loc) · 1.97 KB
/
stdlib.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
macro object_map(o)
{
return @{["postcode", ["get", "o"], ".map"]}@;
}
macro object_prototype(o)
{
return @{["postcode", ["get", "o"], ".prototype"]}@;
}
macro map_property_name(m, idx)
{
return @{["code",
"(function (m, idx) " +
"{" +
" var i = 0;" +
" for (var p in m.payload.properties)" +
" {" +
" if (i === idx)" +
" return symbol(p);" +
" else" +
" i++;" +
" }" +
"})"]}@(m, idx);
}
macro map_count(m)
{
return @{["code",
"(function (m) " +
"{" +
" var i = 0;" +
" for (var p in m.payload.properties)" +
" {" +
" i++;" +
" }" +
" return i;" +
"})"]}@(m);
}
/*
root.object.__itr__ = function ()
{
return {
_obj:this,
_visited:{},
_itr:{map:null},
init:function ()
{
this.next();
return this;
},
valid:function ()
{
return (this._obj !== undefined && this._obj !== null);
},
get:function ()
{
return this._itr.get();
},
next:function ()
{
var r = null;
while (r === null && this.valid())
{
var map = object_map(this._obj);
if (this._itr.map !== map)
{
this._itr = map.__itr__();
}
while (r === null || this._itr.valid())
{
var p = this._itr.get();
if (this._visited[p] !== true)
{
r = p;
this._visited[p] = true;
} else
{
this._itr.next();
}
}
this._obj = object_prototype(this._obj);
}
}
}.init();
};
*/