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 === '::' || v.ctor === '[]')) {
48 var array = List.toArray(v);
49 if (typeof array[0] === 'string') {
50 array = array.join('');
52 for (var i = array.length; i--; ) {
53 array[i] = toJS(array[i]);
61 function fromRecord(r) {
62 if (typeof r === 'object' && '_' in r) {
65 throw new Error("'fromRecord' must be called on a record.");
68 function id(n) { return n; }
70 function toElement(w,h,domNode) {
71 return A3( newElement, w, h, {
74 render: function(node) { return node; },
75 update: function(node,oldNode,newNode) {
76 if (node === newNode) return;
77 node.parentNode.replaceChild(newNode, node);
83 function fromElement(element) {
84 return Render.render(element);
87 return elm.Native.JavaScript = {
90 toInt : function(n) { return n|0; },
91 toString : List.fromArray,
92 toList : List.fromArray,
93 fromString : function(s) { return List.toArray(s).join(''); },
94 fromList : List.toArray,
99 toElement : toElement,
100 fromElement : fromElement,
102 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