2Elm.Native.JavaScript = function(elm) {
5 elm.Native = elm.Native || {};
6 if (elm.Native.JavaScript) return elm.Native.JavaScript;
8 var List = Elm.Native.List(elm);
9 var Render = ElmRuntime.use(ElmRuntime.Render.Element);
13 if (type === 'number' ) return v;
14 if (type === 'boolean') return v;
15 if (type === 'string' ) return List.fromArray(v);
16 if (v instanceof Array) {
19 for (var i = 0; i < len; ++i) {
21 if (x !== null) arr.push(x);
23 return List.fromArray(arr);
25 if (type === 'object') {
29 if (x !== null) rec[f] = x;
38 if (type === 'number' || type === 'boolean') return v;
39 if (type === 'object' && '_' in v) {
43 if (x !== null) obj[k] = x;
47 if (type === 'object' && (v.ctor === 'Cons' || v.ctor === 'Nil')) {
48 var array = List.toArray(v);
49 for (var i = array.length; i--; ) {
50 array[i] = toJS(array[i]);
52 if (typeof array[0] === 'string') array.join('');
58 function fromRecord(r) {
59 if (typeof r === 'object' && '_' in r) {
62 throw new Error("'fromRecord' must be called on a record.");
65 function id(n) { return n; }
67 function toElement(w,h,domNode) {
68 return A3( newElement, w, h, {
71 render: function(node) { return node; },
72 update: function(node,oldNode,newNode) {
73 if (node === newNode) return;
74 node.parentNode.replaceChild(newNode, node);
80 function fromElement(element) {
81 return Render.render(element);
84 return elm.Native.JavaScript = {
87 toInt : function(n) { return n|0; },
88 toString : List.fromArray,
89 toList : List.fromArray,
90 fromString : function(s) { return List.toArray(s).join(''); },
91 fromList : List.toArray,
96 toElement : toElement,
97 fromElement : fromElement,
99 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