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);
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 === 'Cons' || v.ctor === 'Nil')) {
47 var array = List.toArray(v);
48 for (var i = array.length; i--; ) {
49 array[i] = toJS(array[i]);
51 if (typeof array[0] === 'string') array.join('');
57 function fromRecord(r) {
58 if (typeof r === 'object' && '_' in r) {
61 throw new Error("'fromRecord' must be called on a record.");
64 function id(n) { return n }
66 return elm.Native.JavaScript = {
69 toInt : function(n) { return n|0 },
70 toString : function(s) { return List.fromArray(s) },
71 toList : List.fromArray,
72 fromString : function(s) { return List.toArray(s).join('') },
73 fromList : List.toArray,
78 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