made with esnextbin
Created
February 13, 2016 19:16
-
-
Save tylermcginnis/1b9af15fa007d47da5a8 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doAsyncThing () { | |
console.log('Kicking off') | |
return new Promise((res, rej) => { | |
setTimeout(() => res('hi'), 1000) | |
}) | |
} | |
async function doThing () { | |
var val = await doAsyncThing() | |
return val | |
} | |
doThing().then((res) => { | |
console.log(res) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"babel-runtime": "6.3.19" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var _regenerator = require('babel-runtime/regenerator'); | |
var _regenerator2 = _interopRequireDefault(_regenerator); | |
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator'); | |
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | |
var _promise = require('babel-runtime/core-js/promise'); | |
var _promise2 = _interopRequireDefault(_promise); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
function doAsyncThing() { | |
console.log('Kicking off'); | |
return new _promise2.default(function (res, rej) { | |
setTimeout(function () { | |
return res('hi'); | |
}, 1000); | |
}); | |
} | |
var doThing = (function () { | |
var ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() { | |
var val; | |
return _regenerator2.default.wrap(function _callee$(_context) { | |
while (1) { | |
switch (_context.prev = _context.next) { | |
case 0: | |
_context.next = 2; | |
return doAsyncThing(); | |
case 2: | |
val = _context.sent; | |
return _context.abrupt('return', val); | |
case 4: | |
case 'end': | |
return _context.stop(); | |
} | |
} | |
}, _callee, this); | |
})); | |
return function doThing() { | |
return ref.apply(this, arguments); | |
}; | |
})(); | |
doThing().then(function (res) { | |
console.log(res); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment