Skip to content

Commit

Permalink
refactor(#9): refactor reader
Browse files Browse the repository at this point in the history
  • Loading branch information
LVMVRQUXL committed Dec 27, 2021
1 parent 9d869bc commit 1e46cae
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/kotlin/io/github/kotools/csv/Reader.kt
Expand Up @@ -21,6 +21,16 @@ public suspend fun csvReader(configuration: Reader.() -> Unit):
List<Map<String, String>> =
withContext(IO) { delegateCsvReader(configuration) }

/**
* Returns the file's records **asynchronously** according to the given
* [configuration], or throws a [CsvConfigurationException] when the
* [configuration] is invalid or when the targeted file doesn't exist.
*/
public infix fun CoroutineScope.csvReaderAsync(
configuration: Reader.() -> Unit
): Deferred<List<Map<String, String>>> =
async(IO) { delegateCsvReader(configuration) }

/**
* Returns the file's records according to the given [configuration], or returns
* `null` when the [configuration] is invalid or when the targeted file doesn't
Expand Down Expand Up @@ -51,16 +61,6 @@ public suspend fun <T : Any> csvReaderOrNullAs(
configuration: Reader.() -> Unit
): List<T>? = withContext(IO) { delegateCsvReaderOrNullAs(type, configuration) }

/**
* Returns the file's records **asynchronously** according to the given
* [configuration], or throws a [CsvConfigurationException] when the
* [configuration] is invalid or when the targeted file doesn't exist.
*/
public infix fun CoroutineScope.csvReaderAsync(
configuration: Reader.() -> Unit
): Deferred<List<Map<String, String>>> =
async(IO) { delegateCsvReader(configuration) }

/**
* Returns the file's records as a given list of type [T] **asynchronously**
* according to the given [configuration].
Expand Down

0 comments on commit 1e46cae

Please sign in to comment.