Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement toCsv #1

Merged
merged 6 commits into from
Sep 2, 2018
Merged

Implement toCsv #1

merged 6 commits into from
Sep 2, 2018

Conversation

kiramclean
Copy link
Collaborator

Implements toCsv

@coveralls
Copy link

coveralls commented Sep 2, 2018

Pull Request Test Coverage Report for Build 21

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 12: 0.0%
Covered Lines: 78
Relevant Lines: 78

💛 - Coveralls

@@ -0,0 +1,21 @@
import { toString } from "micro-dash";

export function toCsv(data: any[][]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[green]
Maybe "content" instead of "data"?

const string = toString(value);

if (/["|,|\n|\r]/.test(string)) {
return wrapWithQuotes(string.replace(/"/g, `""`));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[yellow]
Should these regular expressions be extracted into constants outside the function? Or doesn't that matter in javascript?

}

function wrapWithQuotes(string: string) {
return `"${string}"`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[green]
This implementation is shorter than the name of the function. Maybe inline it?

@@ -1,21 +1,20 @@
import { toString } from "micro-dash";

export function toCsv(data: any[][]) {
return data
export function toCsv(content: any[][]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[red]
Documentation!

@ersimont ersimont merged commit 143fe2e into master Sep 2, 2018
@ersimont ersimont deleted the write-csvs branch September 2, 2018 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants