Skip to content

Commit d4c92aa

Browse files
committed
Fixed various issues reported by new hires
1 parent b25b115 commit d4c92aa

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/main/ts/Part2Ex2ArrayFunctions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Its array module "Arr" is very handy, so let's explore it.
99
We don't write loops if we can help it. Instead, we go up a level, and call functions that do the looping for us.
1010
The simplest of these is 'each' which just iterates.
1111
12-
TODO: Run the followind code using this command:
12+
TODO: Run the following code using this command:
1313
yarn bedrock-auto -b chrome-headless -f src/test/ts/Exercise2ArrayFunctionsTest.ts
1414
*/
1515

@@ -84,11 +84,11 @@ export const evens = (xs: number[]): number[] =>
8484
// TODO: Write a function that returns all the frogs that ribbit
8585
// TODO: Run the provided test to check your answer.
8686
export const ribbitting = (frogs: Frog[]): Frog[] =>
87-
[]
87+
[];
8888

8989
// TODO: Write a function that returns all frogs aged 8 or older
9090
export const olderFrogs = (frogs: Frog[]): Frog[] =>
91-
[]
91+
[];
9292

9393
/*
9494
5. Arr.exists
@@ -111,7 +111,7 @@ This behaviour of running map then flatten is why this function is sometimes cal
111111
TODO: Write a function that takes a list of strings, each string containing a comma-separated list of values, and returns all of the values as an array.
112112
*/
113113
export const splitCsvs = (csvs: string[]): string[] =>
114-
[]
114+
[];
115115

116116
/*
117117
7. Arr.find

src/main/ts/Part2Ex3Optional.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ value in all cases. Some examples:
1616
1717
There are many ways of representing these "empty" cases, including:
1818
- returning a special value, e.g. empty string, empty array, NaN
19-
- returining null or undefined
19+
- returning null or undefined
2020
- throwing an exception
2121
2222
In TinyMCE, we use a different approach. We represent these scenarios with a data type called "Optional".
@@ -85,7 +85,7 @@ export const message = (e: Optional<string>): string =>
8585
// TODO: Implement a function that takes an Optional<T> for any type T. Return true if it's some, and false if it's none.
8686
const trueIfSome = <T> (x: T): Optional<T> => {
8787
throw new Error("TODO");
88-
}
88+
};
8989

9090
/*
9191
The last function you implemented is already part of the Optional type, and is called isSome().
@@ -99,7 +99,7 @@ export const unsafeStuff = (e: Optional<string>): void => {
9999
if (e.isSome()) {
100100
console.log(e.getOrDie()); // AVOID
101101
}
102-
}
102+
};
103103

104104
/*
105105
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -114,10 +114,10 @@ export const unsafeStuff = (e: Optional<string>): void => {
114114
115115
A common way to handle an Optional value is to provide a default value if in the case of none.
116116
117-
You can do this with fold, but getOrElse is a shortcut.
117+
You can do this with fold, but getOr is a shortcut.
118118
*/
119119

120-
// TODO: Using getOrElse, take an Optional<{age: string}> and turn it into an {age: string}, using a default value of 0.
120+
// TODO: Using getOr, take an Optional<{age: string}> and turn it into an {age: string}, using a default value of 0.
121121

122122
// TODO: Write the same function using fold
123123

src/main/ts/Part2Ex4FP.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fun, Optional } from "@ephox/katamari";
1+
import { Arr, Fun, Optional } from "@ephox/katamari";
22

33
/*
44
Functional programming is about programming in functions. Functions in the mathematical sense. "Pure" functions.
@@ -80,8 +80,8 @@ TODO: Extract a pure function for the logic hiding in this (impure) function
8080
type Mode = 'code' | 'design' | 'markdown';
8181

8282
const switchMode = (m: Mode): void => {
83-
// pretend that something useful happens here
84-
}
83+
// pretend that something useful happens here that causes a side effect
84+
};
8585

8686
const nextMode = (m: Mode): void => {
8787
if (m === 'code') {
@@ -138,7 +138,7 @@ You can find this as Fun.constant in katamari.
138138
One way of writing it is below:
139139
*/
140140

141-
const constant = <A, B> (a: A) => (b: B) => a;
141+
const constant = <A> (a: A) => (...args: any[]): A => a;
142142

143143
const always3 = constant(3);
144144

src/main/ts/Part2Ex5Sugar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ We often have to traverse from an element to its relatives. The Traverse module
5858

5959
// TODO: inspect the type of Traverse.parent and explain why that type was used.
6060
// Answer:
61-
}
61+
};
6262

6363

6464

@@ -76,5 +76,5 @@ We often have to traverse from an element to its relatives. The Traverse module
7676
// TODO: starting at parent, find both kids
7777

7878
// TODO: kid2 grew up - give it its own child node
79-
}
79+
};
8080

src/test/ts/Exercise3OptionTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const tOptional = OptionalInstances.tOptional;
66

77
UnitTest.test('getProtocol', () => {
88
Assert.eq('simple https', Optional.some('https'), Ex.getProtocol('https://frog.com'), tOptional());
9-
Assert.eq('simple http', Optional.some('https'), Ex.getProtocol('http://frog.com'), tOptional());
9+
Assert.eq('simple http', Optional.some('http'), Ex.getProtocol('http://frog.com'), tOptional());
1010
Assert.eq('no protocol 1', Optional.none<string>(), Ex.getProtocol('frog.com'), tOptional());
1111
Assert.eq('no protocol 2', Optional.none<string>(), Ex.getProtocol('://frog.com'), tOptional());
1212
Assert.eq('malformed protocol', Optional.none<string>(), Ex.getProtocol('3ttp://frog.com'), tOptional());

0 commit comments

Comments
 (0)