2module Native.JavaScript where
8 var fromArray = Elm.Native.List.fromArray;
9 var toArray = Elm.Native.List.toArray;
13 if (type === 'number' ) return v;
14 if (type === 'boolean') return v;
15 if (type === 'string' ) return fromArray(v);
16 if (v instanceof Array) {
19 for (var i = 0; i < len; ++i) {
21 if (x !== null) arr.push(x);
23 return 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 = 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 Elm.Native.JavaScript = {
66 id : function(n) { return n },
67 toInt : function(n) { return n|0 },
68 toString : function(s) { return fromArray(s) },
70 fromString : function(s) { return toArray(s).join('') },
73 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