Repository navigation
Expand file tree
/
Copy pathscript-compiled.js
More file actions
100 lines (77 loc) · 2.29 KB
/
Copy pathscript-compiled.js
File metadata and controls
100 lines (77 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
var array = [1, 2, 3];
var newArray = array.map(function (item) {
return Math.pow(item, 2);
});
console.log(newArray);
var _ref = ['hola', 2, 'mundo'],
a = _ref[0],
b = _ref[2];
console.log(a + ' - ' + b);
var _hola$num = {
hola: 'hola mundo :)',
num: 2018
},
hola = _hola$num.hola,
num = _hola$num.num;
console.log(hola + ' -> n\xFAmero ' + num);
// Component react
var _ref2 = React.createElement(
'h4',
null,
'Hello world! :)'
);
var HelloWorld = function HelloWorld(props) {
return React.createElement(
'div',
null,
_ref2,
React.createElement(
'p',
null,
props.name
)
);
};
var app = document.getElementById('app');
ReactDOM.render(React.createElement(HelloWorld, { name: 'John Serrano' }), app);
// Async/Await
var resolveAfter2Seconds = function resolveAfter2Seconds() {
return new Promise(function (resolve) {
setTimeout(function () {
resolve('resolved');
}, 2000);
});
};
// async function asyncCall() {
// console.log('calling');
// var result = await resolveAfter2Seconds();
// console.log(result);
// // expected output: "resolved"
// }
var asyncCall = function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var result;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
console.log('calling');
_context.next = 3;
return resolveAfter2Seconds();
case 3:
result = _context.sent;
console.log(result);
case 5:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
}));
return function asyncCall() {
return _ref3.apply(this, arguments);
};
}();
asyncCall();