Skip to content

Commit

Permalink
New Video Material
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbos committed Sep 25, 2017
1 parent 1db309f commit d59c5f9
Show file tree
Hide file tree
Showing 23 changed files with 4,054 additions and 70 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
.DS_Store
haters/
*.log
updates/
19 changes: 19 additions & 0 deletions 14 - ES6 Tooling/babel-FINISHED/app-compiled.js
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");
});
6 changes: 6 additions & 0 deletions 14 - ES6 Tooling/babel-FINISHED/app.js
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 14 - ES6 Tooling/babel-FINISHED/package-lock.json

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions 14 - ES6 Tooling/babel-FINISHED/package.json
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"
}
}
41 changes: 0 additions & 41 deletions 14 - ES6 Tooling/babel/app-compiled.js

This file was deleted.

8 changes: 1 addition & 7 deletions 14 - ES6 Tooling/babel/app.js
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);
}

22 changes: 0 additions & 22 deletions 14 - ES6 Tooling/babel/package.json

This file was deleted.

14 changes: 14 additions & 0 deletions 20 - Async + Await/Async Await - START.html
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>
47 changes: 47 additions & 0 deletions 20 - Async + Await/Async Await.html
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>
14 changes: 14 additions & 0 deletions 20 - Async + Await/Custom Promise Review-START.html
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>
51 changes: 51 additions & 0 deletions 20 - Async + Await/Custom Promise Review.html
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>
19 changes: 19 additions & 0 deletions 20 - Async + Await/Multiple Promises - START.html
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>
32 changes: 32 additions & 0 deletions 20 - Async + Await/Multiple Promises.html
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>
16 changes: 16 additions & 0 deletions 20 - Async + Await/Native Promises Review-START.html
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>
33 changes: 33 additions & 0 deletions 20 - Async + Await/Native Promises Review.html
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>
Loading

0 comments on commit d59c5f9

Please sign in to comment.