Skip to content

Commit

Permalink
Update docs to reflect Stream.contramap rename to mapInput (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
GraemeF authored Sep 26, 2023
1 parent d159f27 commit dbbc19e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pages/docs/streaming/sink/operations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ In the previous sections, we learned how to create and use sinks. Now, let's exp

## Changing the Input

Sometimes, you have a sink that works perfectly with one type of input, but you want to use it with a different type. This is where `Sink.contramap` comes in handy. While `map` modifies the output of a function, `contramap` modifies the input. It allows you to adapt your sink to work with a different input.
Sometimes, you have a sink that works perfectly with one type of input, but you want to use it with a different type. This is where `Sink.mapInput` comes in handy. While `map` modifies the output of a function, `mapInput` modifies the input. It allows you to adapt your sink to work with a different input.

Imagine you have a `Sink.sum` that calculates the sum of incoming numeric values. However, your stream contains strings, not numbers. You can use `contramap` to convert your strings into numbers and make `Sink.sum` compatible with your stream:
Imagine you have a `Sink.sum` that calculates the sum of incoming numeric values. However, your stream contains strings, not numbers. You can use `mapInput` to convert your strings into numbers and make `Sink.sum` compatible with your stream:

```ts file=<rootDir>/src/streaming/sink/operations/contramap.ts
```ts file=<rootDir>/src/streaming/sink/operations/mapInput.ts

```

## Transforming Both Input and Output

If you need to change both the input and output of a sink, you can use `Sink.dimap`. It's an extended version of `contramap` that lets you transform both types. This can be useful when you need to perform a complete conversion between your input and output types:
If you need to change both the input and output of a sink, you can use `Sink.dimap`. It's an extended version of `mapInput` that lets you transform both types. This can be useful when you need to perform a complete conversion between your input and output types:

```ts file=<rootDir>/src/streaming/sink/operations/dimap.ts

Expand Down
File renamed without changes.

0 comments on commit dbbc19e

Please sign in to comment.