1Elm.Native.JavaScript = {};
2Elm.Native.JavaScript.make = function(elm) {
3 elm.Native = elm.Native || {};
4 elm.Native.JavaScript = elm.Native.JavaScript || {};
5 if (elm.Native.JavaScript.values) return elm.Native.JavaScript.values;
7 var List = Elm.Native.List.make(elm);
8 var Render = ElmRuntime.use(ElmRuntime.Render.Element);
12 if (type === 'number' ) return v;
13 if (type === 'boolean') return v;
14 if (type === 'string' ) return v;
15 if (v instanceof Array) {
18 for (var i = 0; i < len; ++i) {
20 if (x !== null) arr.push(x);
22 return List.fromArray(arr);
24 if (type === 'object') {
28 if (x !== null) rec[f] = x;
37 if (type === 'number' || type === 'boolean' || type === 'string') return v;
38 if (type === 'object' && '_' in v) {
42 if (x !== null) obj[k] = x;
46 if (type === 'object' && (v.ctor === '::' || v.ctor === '[]')) {
47 var array = List.toArray(v);
48 for (var i = array.length; i--; ) {
49 array[i] = toJS(array[i]);
56 function fromRecord(r) {
57 if (typeof r === 'object' && '_' in r) {
60 throw new Error("'fromRecord' must be called on a record.");
63 function id(n) { return n; }
65 function toElement(w,h,domNode) {
66 return A3( newElement, w, h, {
69 render: function(node) { return node; },
70 update: function(node,oldNode,newNode) {
71 if (node === newNode) return;
72 node.parentNode.replaceChild(newNode, node);
78 function fromElement(element) {
79 return Render.render(element);
82 return elm.Native.JavaScript.values = {
83 toInt : function(n) { return n|0; },
84 toFloat : function(n) { return +n; },
87 toList : List.fromArray,
89 fromList : List.toArray,
94 toElement : toElement,
95 fromElement : fromElement,
97 fromRecord : fromRecord
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list