-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(grid): move traversers to traversers folder and add utils folder…
… with forEach and map The `forEach()` function is aliased to `tap()`. These utils are curried and used in `Grid.each()` and `Grid.map()`.
- Loading branch information
1 parent
65750d0
commit 751be5a
Showing
10 changed files
with
35 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './constants' | ||
export * from './functions' | ||
export * from './grid' | ||
export * from './traversers' | ||
export * from './types' | ||
export * from './utils' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export * from './at' | ||
export * from './branch' | ||
export * from './concat' | ||
export * from './move' | ||
export * from './rectangle' | ||
export * from './repeat' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const forEach = <T>(fn: (value: T) => void) => (iterable: Iterable<T>) => { | ||
for (const value of iterable) { | ||
fn(value) | ||
} | ||
return iterable | ||
} | ||
|
||
export const tap = forEach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './forEach' | ||
export * from './map' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const map = <T>(fn: (value: T) => T) => (iterable: Iterable<T>) => { | ||
const result: T[] = [] | ||
for (const value of iterable) { | ||
result.push(fn(value)) | ||
} | ||
return result | ||
} |