forked from wesbos/es6.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
4,054 additions
and
70 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules/ | |
.DS_Store | ||
haters/ | ||
*.log | ||
updates/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
|
||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
|
||
var _x$y$a$b = { | ||
x: 1, | ||
y: 2, | ||
a: 3, | ||
b: 4 | ||
}, | ||
x = _x$y$a$b.x, | ||
y = _x$y$a$b.y, | ||
z = _objectWithoutProperties(_x$y$a$b, ["x", "y"]); | ||
|
||
var age = 100; | ||
var people = ['Wes', 'Kait']; | ||
var fullNames = people.map(function (name) { | ||
return "".concat(name, " Bos"); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; | ||
|
||
const age = 100; | ||
const people = ['Wes', 'Kait']; | ||
|
||
const fullNames = people.map(name => `${name} Bos`); |
3,557 changes: 3,557 additions & 0 deletions
3,557
14 - ES6 Tooling/babel-FINISHED/package-lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "babel", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "app.js", | ||
"scripts": { | ||
"babel": "babel app.js --watch --out-file app-compiled.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"babel-cli": "^7.0.0-beta.1", | ||
"babel-preset-env": "^2.0.0-beta.1" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"browsers": [ | ||
"last 2 versions", | ||
"safari >= 8" | ||
] | ||
} | ||
} | ||
] | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread" | ||
] | ||
}, | ||
"devDependencies": { | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; | ||
|
||
const { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; | ||
|
||
const age = 100; | ||
const people = ['Wes', 'Kait']; | ||
|
||
const fullNames = people.map(name => `${name} Bos`); | ||
|
||
for(const person of people) { | ||
console.log(person); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Custom Promises</title> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
|
||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Async Await</title> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
function breathe(amount) { | ||
return new Promise((resolve, reject) => { | ||
if (amount < 500) { | ||
reject('That is too small of a value'); | ||
} | ||
setTimeout(() => resolve(`Done for ${amount} ms`), amount); | ||
}); | ||
} | ||
|
||
function catchErrors(fn) { | ||
return function (...args) { | ||
return fn(...args).catch((err) => { | ||
console.error('Ohhhh nooo!!!!!'); | ||
console.error(err); | ||
}); | ||
} | ||
} | ||
|
||
async function go(name, last) { | ||
console.log(`Starting for ${name} ${last}!`); | ||
const res = await breathe(1000); | ||
console.log(res); | ||
const res2 = await breathe(300); | ||
console.log(res2); | ||
const res3 = await breathe(750); | ||
console.log(res3); | ||
const res4 = await breathe(900); | ||
console.log(res4); | ||
console.log('end'); | ||
} | ||
|
||
const wrappedFunction = catchErrors(go); | ||
|
||
wrappedFunction('Wes', 'Bos'); | ||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Custom Promises</title> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
|
||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Custom Promises</title> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
function breathe(amount) { | ||
return new Promise((resolve, reject) => { | ||
if (amount < 500) { | ||
reject('That is too small of a value'); | ||
} | ||
setTimeout(() => resolve(`Done for ${amount} ms`), amount); | ||
}); | ||
} | ||
|
||
breathe(1000).then(res => { | ||
console.log(res); | ||
return breathe(500); | ||
}).then(res => { | ||
console.log(res); | ||
return breathe(600); | ||
}).then(res => { | ||
console.log(res); | ||
return breathe(200); | ||
}).then(res => { | ||
console.log(res); | ||
return breathe(500); | ||
}).then(res => { | ||
console.log(res); | ||
return breathe(2000); | ||
}).then(res => { | ||
console.log(res); | ||
return breathe(250); | ||
}).then(res => { | ||
console.log(res); | ||
return breathe(300); | ||
}).then(res => { | ||
console.log(res); | ||
return breathe(600); | ||
}).catch(err => { | ||
console.error(err); | ||
console.error('YOU SCHREWED UP'); | ||
|
||
}) | ||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Async Await</title> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
async function go() { | ||
const p1 = fetch('https://api.github.com/users/wesbos'); | ||
const p2 = fetch('https://api.github.com/users/stolinski'); | ||
} | ||
|
||
go(); | ||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Async Await</title> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
// async function go() { | ||
// const p1 = fetch('https://api.github.com/users/wesbos'); | ||
// const p2 = fetch('https://api.github.com/users/stolinski'); | ||
// // Wait for both of them to come back | ||
// const res = await Promise.all([p1, p2]); | ||
// const dataPromises = res.map(r => r.json()); | ||
// const [wes, scott] = await Promise.all(dataPromises); | ||
// console.log(wes, scott); | ||
// } | ||
|
||
// go(); | ||
|
||
async function getData(names) { | ||
const promises = names.map(name => fetch(`https://api.github.com/users/${name}`).then(r => r.json())); | ||
const people = await Promise.all(promises); | ||
console.log(people); | ||
} | ||
|
||
getData(['wesbos', 'stolinski', 'darcyclarke']); | ||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Native Promises</title> | ||
</head> | ||
|
||
<video controls class="handsome"></video> | ||
|
||
<body> | ||
<script> | ||
|
||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Native Promises</title> | ||
</head> | ||
|
||
<video controls class="handsome"></video> | ||
|
||
<body> | ||
<script> | ||
// fetch('api.github.com/users/wesbos').then(res => { | ||
// return res.json(); | ||
// }).then(res => { | ||
// console.log(res); | ||
// }).catch(err => { | ||
// console.error('OH NOO!!!!!!!'); | ||
// console.error(err); | ||
// }) | ||
|
||
const video = document.querySelector('.handsome'); | ||
|
||
navigator.mediaDevices.getUserMedia({ video: true }).then(mediaStream => { | ||
video.srcObject = mediaStream; | ||
video.load(); | ||
video.play(); | ||
}).catch(err => { | ||
console.log(err); | ||
}) | ||
</script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.