Skip to content

Commit

Permalink
feat(map): remove 'flap_map' in favour of 'map' with spread as last expr
Browse files Browse the repository at this point in the history
    BREAKING CHANGE: 'flat_map' removed in favour of 'map' with spread as last expr
  • Loading branch information
kollhof committed May 1, 2020
1 parent 618147a commit c082d28
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 38 deletions.
3 changes: 1 addition & 2 deletions src/lang/iterable/index.fnk
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
10 changes: 2 additions & 8 deletions src/lang/iterable/map.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@



transform_any = fn flatten: fn node, ctx:
transform_map = fn node, ctx:
{transform, unique_ident} = ctx

item = unique_ident:: 'item'
Expand All @@ -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
10 changes: 0 additions & 10 deletions src/lang/iterable/map.test.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -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




Expand Down
18 changes: 0 additions & 18 deletions src/lang/iterable/map.test.fnk.snap
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit c082d28

Please sign in to comment.