Skip to content

Instantly share code, notes, and snippets.

@MichalZalecki MichalZalecki/pointsSum.ts Secret
Created Apr 23, 2019

Embed
What would you like to do?
import { PathReporter } from "io-ts/lib/PathReporter";
const pointsSum = posts.map(post => post.hits.reduce((s, p) => s + p.points, 0));
if (pointsSum.isRight()) {
console.log(`Sum of points is ${pointsSum.value}`);
} else {
console.log(PathReporter.report(pointsSum));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.