-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adopt type=module follow changes in d3-format: * type=module * add exports * remove zip * license: ISC * update dependencies * update dependencies * bin/*.js * Update README * cleaner imports * remove Sublime project * add eslint.json Co-authored-by: Mike Bostock <[email protected]>
- Loading branch information
Showing
20 changed files
with
1,475 additions
and
1,418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "eslint-compact", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"severity": 4, | ||
"message": 5, | ||
"code": 6 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: yarn --frozen-lockfile | ||
- run: | | ||
echo ::add-matcher::.github/eslint.json | ||
yarn run eslint src test --format=compact | ||
- run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,13 @@ | ||
Copyright 2013-2016 Mike Bostock | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the author nor the names of contributors may be used to | ||
endorse or promote products derived from this software without specific prior | ||
written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
Copyright 2013-2021 Mike Bostock | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose | ||
with or without fee is hereby granted, provided that the above copyright notice | ||
and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env node | ||
|
||
import {EOL} from "os"; | ||
import {basename, dirname, resolve} from "path"; | ||
import {readFileSync} from "fs"; | ||
import {fileURLToPath} from "url"; | ||
import rw from "rw"; | ||
import {program} from "commander"; | ||
import iconv from "iconv-lite"; | ||
import {dsvFormat} from "../src/index.js"; | ||
|
||
const progname = basename(process.argv[1]); | ||
const defaultInDelimiter = progname.slice(0, 3) === "tsv" ? "\t" : ","; | ||
const defaultOutDelimiter = progname.slice(-3) === "tsv" ? "\t" : ","; | ||
|
||
const options = program | ||
.version(JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json"))).version) | ||
.usage("[options] [file]") | ||
.option("-o, --out <file>", "output file name; defaults to “-” for stdout", "-") | ||
.option("-r, --input-delimiter <character>", "input delimiter character", defaultInDelimiter) | ||
.option("-w, --output-delimiter <character>", "output delimiter character", defaultOutDelimiter) | ||
.option("--input-encoding <encoding>", "input character encoding; defaults to “utf8”", "utf8") | ||
.option("--output-encoding <encoding>", "output character encoding; defaults to “utf8”", "utf8") | ||
.parse(process.argv) | ||
.opts(); | ||
|
||
const inFormat = dsvFormat(options.inputDelimiter); | ||
const outFormat = dsvFormat(options.outputDelimiter); | ||
|
||
rw.dash.readFile(program.args[0] || "-", (error, text) => { | ||
if (error) throw error; | ||
rw.dash.writeFile("-", iconv.encode(outFormat.format(inFormat.parse(iconv.decode(text, options.inputEncoding))) + EOL, options.outputEncoding), (error) => { | ||
if (error) throw error; | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env node | ||
|
||
import {EOL} from "os"; | ||
import {basename, dirname, resolve} from "path"; | ||
import {readFileSync} from "fs"; | ||
import {fileURLToPath} from "url"; | ||
import rw from "rw"; | ||
import {program} from "commander"; | ||
import iconv from "iconv-lite"; | ||
import {dsvFormat} from "../src/index.js"; | ||
|
||
const progname = basename(process.argv[1]); | ||
const defaultInDelimiter = progname.slice(0, 3) === "tsv" ? "\t" : ","; | ||
|
||
const options = program | ||
.version(JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json"))).version) | ||
.usage("[options] [file]") | ||
.option("-o, --out <file>", "output file name; defaults to “-” for stdout", "-") | ||
.option("-r, --input-delimiter <character>", "input delimiter character", defaultInDelimiter) | ||
.option("-a, --auto-type", "parse rows with type inference (see d3.autoType)") | ||
.option("-n, --newline-delimited", "output newline-delimited JSON") | ||
.option("--input-encoding <encoding>", "input character encoding; defaults to “utf8”", "utf8") | ||
.option("--output-encoding <encoding>", "output character encoding; defaults to “utf8”", "utf8") | ||
.parse(process.argv) | ||
.opts(); | ||
|
||
const inFormat = dsvFormat(options.inputDelimiter); | ||
|
||
rw.dash.readFile(program.args[0] || "-", (error, text) => { | ||
if (error) throw error; | ||
const rowConverter = options.autoType ? dsv.autoType : null | ||
const rows = inFormat.parse(iconv.decode(text, options.inputEncoding), rowConverter); | ||
rw.dash.writeFile(options.out, iconv.encode(options.newlineDelimited | ||
? rows.map((row) => JSON.stringify(row)).join("\n") + "\n" | ||
: JSON.stringify(rows) + EOL, options.outputEncoding), (error) => { | ||
if (error) throw error; | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.