Skip to content

Commit 0f67fa6

Browse files
committed
Upgraded code samples to Angular CLI 1.3.0
1 parent 97fba4b commit 0f67fa6

File tree

12 files changed

+4593
-1357
lines changed

12 files changed

+4593
-1357
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function* getStockPrice(symbol){
2+
3+
while(true){
4+
yield Math.random()*100;
5+
6+
console.log(`resuming for ${symbol}`);
7+
}
8+
}
9+
10+
const priceGenerator = getStockPrice("IBM");
11+
12+
const limitPrice = 15;
13+
const price = 100;
14+
15+
while ( price > limitPrice){
16+
17+
price = priceGenerator.next().value;
18+
console.log (`The generator returned ${price}`);
19+
}
20+
21+
console.log(`buying at ${price} !!!`);

SecondEdition/appendixA/rest.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// ES5 and arguments object
2+
function calcTaxES5(){
3+
4+
console.log("ES5. Calculating tax for customers with the income ",
5+
arguments[0]); // income is the first element
6+
7+
// extract an array starting from 2nd element
8+
var customers = [].slice.call(arguments, 1);
9+
10+
customers.forEach(function (customer) {
11+
console.log("Processing ", customer);
12+
});
13+
}
14+
15+
calcTaxES5(50000, "Smith", "Johnson", "McDonald");
16+
calcTaxES5(750000, "Olson", "Clinton");
17+
18+
// ES6 and rest operator
19+
function calcTaxES6(income, ...customers) {
20+
console.log("ES6. Calculating tax for customers with the income ", income);
21+
22+
customers.forEach(function (customer) {
23+
console.log("Processing ", customer);
24+
});
25+
}
26+
27+
calcTaxES6(50000, "Smith", "Johnson", "McDonald");
28+
calcTaxES6(750000, "Olson", "Clinton");

0 commit comments

Comments
 (0)