Skip to content

Commit

Permalink
Require Node.js 10
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 7, 2020
1 parent 8380e65 commit b4af659
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 19 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 14
- 12
- 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

4 changes: 1 addition & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {Options as CsvParserOptions} from 'csv-parser';
declare namespace neatCsv {
type Options = CsvParserOptions;

interface Row {
[header: string]: string;
}
type Row = Record<string, string>;
}

/**
Expand Down
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
'use strict';
const {promisify} = require('util');
const {pipeline} = require('stream');
const toReadableStream = require('to-readable-stream');
const csvParser = require('csv-parser');
const getStream = require('get-stream');
// TODO: Use `const {pipeline: pipelinePromise} = require('stream/promises');` when targeting Node.js 16.

const pipelinePromise = promisify(pipeline);

module.exports = async (data, options) => {
if (typeof data === 'string' || Buffer.isBuffer(data)) {
// TODO: Use https://nodejs.org/api/stream.html#stream_stream_readable_from_iterable_options when targeting Node.js 12.
data = toReadableStream(data);
}

// TODO: Use `stream.pipeline` here when targeting Node.js 10
return getStream.array(data.pipe(csvParser(options)));
const parserStream = csvParser(options);
await pipelinePromise([data, parserStream]);
return getStream.array(parserStream);
};
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=8"
"node": ">=10"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -36,13 +36,13 @@
"parser"
],
"dependencies": {
"csv-parser": "^2.3.2",
"get-stream": "^5.1.0",
"csv-parser": "^3.0.0",
"get-stream": "^6.0.0",
"to-readable-stream": "^2.1.0"
},
"devDependencies": {
"ava": "^2.1.0",
"tsd": "^0.11.0",
"xo": "^0.25.4"
"ava": "^2.4.0",
"tsd": "^0.14.0",
"xo": "^0.35.0"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# neat-csv [![Build Status](https://travis-ci.org/sindresorhus/neat-csv.svg?branch=master)](https://travis-ci.org/sindresorhus/neat-csv)
# neat-csv

> Fast CSV parser
Expand Down

0 comments on commit b4af659

Please sign in to comment.