From c082d284d1374c8fb9355cfc033ea327015d5955 Mon Sep 17 00:00:00 2001 From: Jan Klaas Kollhof Date: Fri, 1 May 2020 19:15:18 +0200 Subject: [PATCH] feat(map): remove 'flap_map' in favour of 'map' with spread as last expr BREAKING CHANGE: 'flat_map' removed in favour of 'map' with spread as last expr --- src/lang/iterable/index.fnk | 3 +-- src/lang/iterable/map.fnk | 10 ++-------- src/lang/iterable/map.test.fnk | 10 ---------- src/lang/iterable/map.test.fnk.snap | 18 ------------------ 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/lang/iterable/index.fnk b/src/lang/iterable/index.fnk index c457359..e1ad2a9 100644 --- a/src/lang/iterable/index.fnk +++ b/src/lang/iterable/index.fnk @@ -1,7 +1,7 @@ {add, any} = import '../context' {transform_fold} = import './fold' {transform_unfold} = import './unfold' -{transform_map, transform_flat_map} = import './map' +{transform_map} = import './map' {transform_filter} = import './filter' {transform_while} = import './while' {transform_find} = import './find' @@ -12,7 +12,6 @@ add_iterables = fn ctx: add:: any, 'fold', transform_fold add:: any, 'unfold', transform_unfold add:: any, 'map', transform_map - add:: any, 'flat_map', transform_flat_map add:: any, 'filter', transform_filter add:: any, 'while', transform_while add:: any, 'find', transform_find diff --git a/src/lang/iterable/map.fnk b/src/lang/iterable/map.fnk index 349b64a..736e3fd 100644 --- a/src/lang/iterable/map.fnk +++ b/src/lang/iterable/map.fnk @@ -5,7 +5,7 @@ -transform_any = fn flatten: fn node, ctx: +transform_map = fn node, ctx: {transform, unique_ident} = ctx item = unique_ident:: 'item' @@ -31,10 +31,4 @@ transform_any = fn flatten: fn node, ctx: yields:: transform:: yield_value - flatten || last_is_spread - - -transform_map = transform_any:: false - - -transform_flat_map = transform_any:: true + last_is_spread diff --git a/src/lang/iterable/map.test.fnk b/src/lang/iterable/map.test.fnk index 7fd0818..b88e744 100644 --- a/src/lang/iterable/map.test.fnk +++ b/src/lang/iterable/map.test.fnk @@ -66,16 +66,6 @@ describe:: 'map', fn: ` to_match_snapshot -describe:: 'flat_map', fn: - it:: 'compiles', fn: - expect:: - fink2js` - flat_map item: [spam + item] - - flat_map item: [spam] - ` - to_match_snapshot - diff --git a/src/lang/iterable/map.test.fnk.snap b/src/lang/iterable/map.test.fnk.snap index 4bb0daf..538c352 100644 --- a/src/lang/iterable/map.test.fnk.snap +++ b/src/lang/iterable/map.test.fnk.snap @@ -1,23 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`flat_map compiles 1`] = ` -"(function* map(ˆitems_2) { - for (const ˆitem_1 of ˆitems_2) { - const item = ˆitem_1; - yield* [spam + item]; - } -}); - -(function* map(ˆitems_4) { - for (const ˆitem_3 of ˆitems_4) { - const item = ˆitem_3; - yield* [spam]; - } -}); - -Object.assign(module.exports, {});" -`; - exports[`map compiles as flat map 1`] = ` "(function* map(ˆitems_2) { for (const ˆitem_1 of ˆitems_2) {