From 6c89ca79fe157a913d2043083aeef6a1bd45c8e3 Mon Sep 17 00:00:00 2001 From: cyclane Date: Mon, 19 Jul 2021 02:40:54 +0100 Subject: [PATCH] Added length filter --- .../api/graphs/[graph]/[profile]/[player].ts | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/routes/api/graphs/[graph]/[profile]/[player].ts b/src/routes/api/graphs/[graph]/[profile]/[player].ts index d5bef61..485b44a 100644 --- a/src/routes/api/graphs/[graph]/[profile]/[player].ts +++ b/src/routes/api/graphs/[graph]/[profile]/[player].ts @@ -58,20 +58,22 @@ export async function get( let d: [string, number, number][][] = data; res.end( JSON.stringify( - d.map((values, idx) => { - return values.filter(value => { - return ( - idx === 0 || - idx === d.length - 1 || - d[idx - 1].find( - v => v[0] === value[0] - )?.[2] !== value[2] || - d[idx + 1].find( - v => v[0] === value[0] - )?.[2] !== value[2] - ); - }); - }) + d + .map((values, idx) => { + return values.filter(value => { + return ( + idx === 0 || + idx === d.length - 1 || + d[idx - 1].find( + v => v[0] === value[0] + )?.[2] !== value[2] || + d[idx + 1].find( + v => v[0] === value[0] + )?.[2] !== value[2] + ); + }); + }) + .filter(v => v.length > 0) ) ); }