Skip to content

Commit ff4dce8

Browse files
authored
Merge pull request #233 from mrodrig/tsify
Migrate to TypeScript
2 parents c54692f + b87a7b1 commit ff4dce8

39 files changed

+3377
-3316
lines changed

.eslintrc

Lines changed: 0 additions & 127 deletions
This file was deleted.

.eslintrc.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
es2022: true,
5+
node: true,
6+
mocha: true,
7+
},
8+
parserOptions: {
9+
ecmaVersion: 13,
10+
project: ['tsconfig.json'],
11+
sourceType: 'module',
12+
tsconfigRootDir: __dirname,
13+
},
14+
extends: [
15+
'eslint:recommended',
16+
'plugin:import/errors',
17+
'plugin:import/warnings',
18+
'plugin:import/typescript',
19+
'plugin:@typescript-eslint/recommended',
20+
],
21+
parser: '@typescript-eslint/parser',
22+
ignorePatterns: [
23+
'/lib/**/*', // Ignore built files.
24+
],
25+
plugins: [
26+
'@typescript-eslint',
27+
'import',
28+
],
29+
rules: {
30+
// Basic ES6
31+
indent: [
32+
'error', 4, { // use 4 spaces for indents
33+
'SwitchCase': 1, // indent case within switch
34+
}
35+
],
36+
'linebreak-style': 0, // mixed environment let git config enforce line endings
37+
quotes: ['error', 'single'],
38+
semi: ['error', 'always'],
39+
'no-var': 'error',
40+
'no-console': 0, // allow use of console.log,
41+
'arrow-body-style': [0, 'always'],
42+
'max-len': 0,
43+
'camelcase': 1,
44+
'import/no-unresolved': [
45+
'error', {
46+
// https://github.com/firebase/firebase-admin-node/discussions/1359
47+
ignore: ['^firebase-admin/.+'],
48+
},
49+
],
50+
'@typescript-eslint/consistent-type-definitions': 'warn'
51+
},
52+
};

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ node_modules
1010

1111
# Debug logs
1212
npm-debug.log
13+
14+
# Built JavaScript files
15+
lib

.npmignore

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
test/
2-
.git*
1+
# Debug Logs
32
npm-debug.log
4-
.travis.yml
5-
.eslintrc
6-
node_modules
7-
coverage
3+
4+
# Uncompiled Source Files
5+
src
6+
test
7+
8+
# Node Modules
9+
node_modules/
10+
node_modules/*
11+
12+
# Configuration Files
13+
.eslintrc*
14+
tsconfig*
15+
16+
# Test/Coverage Files
17+
coverage/
18+
coverage/*
19+
.nycrc
820
.nyc_output
9-
upgrade_guides
10-
tslint.json
11-
_config.yml
21+
.nyc_output/*
1222
.coveralls.yml
23+
lib/test
24+
25+
# Github Configuration Files
26+
_config.yml
27+
.git*
28+
29+
# Extra documentation files
30+
upgrade_guides/*

.nycrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"check-coverage": true,
3+
"all": true,
4+
"include": [
5+
"src/**/!(*.test.*).[tj]s?(x)"
6+
],
7+
"exclude": [
8+
"test/**/*.*"
9+
],
10+
"reporter": [
11+
"lcov",
12+
"text-summary",
13+
"text"
14+
],
15+
"report-dir": "coverage"
16+
}

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2014-2020 Michael Rodrigues
3+
Copyright (c) 2014-Present Michael Rodrigues
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# json-2-csv
22
**Convert JSON to CSV _or_ CSV to JSON**
33

4-
[![Dependencies](https://img.shields.io/librariesio/release/npm/json-2-csv)](https://www.npmjs.org/package/json-2-csv)
5-
[![Downloads](https://img.shields.io/npm/dm/json-2-csv.svg)](https://www.npmjs.org/package/json-2-csv)
64
[![NPM version](https://img.shields.io/npm/v/json-2-csv.svg)](https://www.npmjs.org/package/json-2-csv)
5+
[![Typings](https://img.shields.io/npm/types/json-2-csv)](https://www.npmjs.org/package/json-2-csv)
6+
[![Downloads](https://img.shields.io/npm/dm/json-2-csv.svg)](https://www.npmjs.org/package/json-2-csv)
77
[![Minzipped Size](https://img.shields.io/bundlephobia/minzip/json-2-csv)](https://bundlephobia.com/result?p=json-2-csv)
88

99
[![Build Status](https://travis-ci.org/mrodrig/json-2-csv.svg?branch=master)](https://travis-ci.org/mrodrig/json-2-csv)
1010
[![Coverage Status](https://coveralls.io/repos/github/mrodrig/json-2-csv/badge.svg?branch=stable)](https://coveralls.io/github/mrodrig/json-2-csv?branch=stable)
1111
[![Maintainability](https://api.codeclimate.com/v1/badges/8c0cc3699d054fb77abe/maintainability)](https://codeclimate.com/github/mrodrig/json-2-csv/maintainability)
12-
[![Typings](https://img.shields.io/npm/types/json-2-csv)](https://www.npmjs.org/package/json-2-csv)
1312

1413
This node module will convert an array of JSON documents to a CSV string.
1514
Column headings will be automatically generated based on the keys of the JSON documents. Nested documents will have a '.' appended between the keys.
@@ -30,12 +29,13 @@ $ npm install @mrodrig/json-2-csv-cli
3029

3130
## Upgrading?
3231

33-
Upgrading to v3 from v2? Check out the [upgrade guide](https://github.com/mrodrig/json-2-csv/blob/master/upgrade_guides/UPGRADE_2_to_3.md).
32+
Upgrading to v4 from v3? Check out the [upgrade guide](https://github.com/mrodrig/json-2-csv/blob/master/upgrade_guides/UPGRADE_3_to_4.md).
3433

3534
## Usage
3635

3736
```javascript
3837
let converter = require('json-2-csv');
38+
const csv = await converter.json2csv(data, options);
3939
```
4040
or
4141
```javascript
@@ -45,11 +45,9 @@ Looking for examples? Check out the Wiki: [json-2-csv Wiki](https://github.com/m
4545

4646
### API
4747

48-
#### `converter.json2csv(array, callback, options)`
48+
#### `json2csv(array, options)`
4949

5050
* `array` - An array of JSON documents to be converted to CSV.
51-
* `callback` - A function of the form `function (err, csv)`;
52-
* This function will receive any errors and/or the string of CSV generated.
5351
* `options` - (Optional) A JSON document specifying any of the following key value pairs:
5452
* `checkSchemaDifferences` - Boolean - Should all documents have the same schema?
5553
* Default: `false`
@@ -146,14 +144,9 @@ Looking for examples? Check out the Wiki: [json-2-csv Wiki](https://github.com/m
146144

147145
For examples, please refer to the [json2csv API Documentation (Link)](https://github.com/mrodrig/json-2-csv/wiki/json2csv-Documentation)
148146

149-
#### Promisified Version: `converter.json2csvAsync(array, options)`
150-
151-
Available in version `2.2.0`, this functionality makes use of promises from the `bluebird` module.
152-
153-
#### `converter.csv2json(csv, callback, options)`
147+
#### `csv2json(csv, options)`
154148

155149
* `csv` - A string of CSV
156-
* `callback` - A function of the form `function (err, array)`; This function will receive any errors and/or the array of JSON documents generated.
157150
* `options` - (Optional) A JSON document specifying any of the following key value pairs:
158151
* `delimiter` - Document - Specifies the different types of delimiters
159152
* `field` - String - Field Delimiter.
@@ -181,10 +174,6 @@ Available in version `2.2.0`, this functionality makes use of promises from the
181174

182175
For examples, please refer to the [csv2json API Documentation (Link)](https://github.com/mrodrig/json-2-csv/wiki/csv2json-Documentation)
183176

184-
#### Promisified Version: `csv2jsonAsync(csv, options)`
185-
186-
Available in version `2.2.0`, this functionality makes use of promises from the `bluebird` module.
187-
188177
### CLI
189178
Note: As of `3.5.8`, the command line interface functionality has been pulled out to a separate package. Please be sure to
190179
install the `@mrodrig/json-2-csv-cli` NPM package if you wish to use the CLI functionality shown below:
@@ -244,14 +233,6 @@ To see test coverage, please run:
244233
$ npm run coverage
245234
```
246235

247-
Current Coverage is:
248-
```
249-
Statements : 100% ( 286/286 )
250-
Branches : 100% ( 166/166 )
251-
Functions : 100% ( 73/73 )
252-
Lines : 100% ( 280/280 )
253-
```
254-
255236
## Frequently Asked Questions (FAQ)
256237
Please find the updated list (relocated to the Wiki) here: [Frequently Asked Questions (Link)](https://github.com/mrodrig/json-2-csv/wiki/FAQ)
257238

0 commit comments

Comments
 (0)