Skip to content

Instantly share code, notes, and snippets.

@MichalZalecki
Created April 23, 2019 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichalZalecki/260ac7f2d82481ba3173085d2e253386 to your computer and use it in GitHub Desktop.
Save MichalZalecki/260ac7f2d82481ba3173085d2e253386 to your computer and use it in GitHub Desktop.
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