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 List.fromArray(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') 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 if (typeof array[0] === 'string') {
49 array = array.join('');
51 for (var i = array.length; i--; ) {
52 array[i] = toJS(array[i]);
60 function fromRecord(r) {
61 if (typeof r === 'object' && '_' in r) {
64 throw new Error("'fromRecord' must be called on a record.");
67 function id(n) { return n; }
69 function toElement(w,h,domNode) {
70 return A3( newElement, w, h, {
73 render: function(node) { return node; },
74 update: function(node,oldNode,newNode) {
75 if (node === newNode) return;
76 node.parentNode.replaceChild(newNode, node);
82 function fromElement(element) {
83 return Render.render(element);
86 return elm.Native.JavaScript.values = {
87 toInt : function(n) { return n|0; },
88 toFloat : function(n) { return +n; },
91 toList : List.fromArray,
93 fromList : List.toArray,
98 toElement : toElement,
99 fromElement : fromElement,
101 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