Hi all! Hope it helps... Here are some interesting cases with Pipeline tap operator |:
case1: Pipeline tap operator |:
and Ternary Comparison Assignment Operators:
const result = someData
|> someData.filter(x => x >= 10) ? "true" : "false";
case2: Pipeline tap operator |:
and Optional Primitive Type Annotation and Ternary Comparison Assignment Operators and Ternary-like try/catch:
function test1(a: string): string {
return a.toUpperCase();
}
const result = someData
|> someData.filter(x => x >= 10) try? test1('value1'): "false"; // if sucess call test1 ... catch "false"
case3: Pipeline tap operator |:
and Concurrent Async and Normal Await Evaluation Blocks and Ternary-like try/catch:
const data = {
x: awaitmulti getX(),
y: await.multi getY(),
}
const result = data
|> data.filter(x => x >= 10) try? "true": "false"; // if sucess true ... catch "false"
case4: Pipeline tap operator |:
and Class property parameters
class DataStorage {
constructor(this value) {}
}
const result = someData
|> someData.filter(x => x >= 10) ? DataStorage(x) : "false";
references
- Ternary-like try/catch
- Ternary Comparison Assignment Operators
- Optional Primitive Type Annotation
- GitHub - tc39/proposal-type-annotations: ECMAScript proposal for type syntax that is erased - Stage 1
- GitHub - sirisian/ecmascript-types: ECMAScript Optional Static Typing Proposal http://sirisian.github.io/ecmascript-types/
- Logical assignment for default assignments
- Try-catch oneliner - #8 by coderaiser
- If-only Ternary Operation
- Concurrent Async and Normal Await Evaluation Blocks
- GitHub - acutmore/proposal-parameter-properties: inline class fields in constructor parameters
- Class property parameters
- GitHub - jrandolf-zz/proposal-logical-default-assignment: Logical assignment for default assignments
- Try-catch oneliner - #8 by coderaiser