1Elm.Native.JavaScript = {};
2Elm.Native.JavaScript.make = function(elm) {
3 elm.Native = elm.Native || {};
4 if (elm.Native.JavaScript) return elm.Native.JavaScript;
6 var List = Elm.Native.List.make(elm);
7 var Render = ElmRuntime.use(ElmRuntime.Render.Element);
11 if (type === 'number' ) return v;
12 if (type === 'boolean') return v;
13 if (type === 'string' ) return List.fromArray(v);
14 if (v instanceof Array) {
17 for (var i = 0; i < len; ++i) {
19 if (x !== null) arr.push(x);
21 return List.fromArray(arr);
23 if (type === 'object') {
27 if (x !== null) rec[f] = x;
36 if (type === 'number' || type === 'boolean') return v;
37 if (type === 'object' && '_' in v) {
41 if (x !== null) obj[k] = x;
45 if (type === 'object' && (v.ctor === '::' || v.ctor === '[]')) {
46 var array = List.toArray(v);
47 if (typeof array[0] === 'string') {
48 array = array.join('');
50 for (var i = array.length; i--; ) {
51 array[i] = toJS(array[i]);
59 function fromRecord(r) {
60 if (typeof r === 'object' && '_' in r) {
63 throw new Error("'fromRecord' must be called on a record.");
66 function id(n) { return n; }
68 function toElement(w,h,domNode) {
69 return A3( newElement, w, h, {
72 render: function(node) { return node; },
73 update: function(node,oldNode,newNode) {
74 if (node === newNode) return;
75 node.parentNode.replaceChild(newNode, node);
81 function fromElement(element) {
82 return Render.render(element);
85 return elm.Native.JavaScript = {
88 toInt : function(n) { return n|0; },
89 toString : List.fromArray,
90 toList : List.fromArray,
91 fromString : function(s) { return List.toArray(s).join(''); },
92 fromList : List.toArray,
97 toElement : toElement,
98 fromElement : fromElement,
100 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