Skip to content

Commit

Permalink
Update types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 31, 2022
1 parent 8b38b1a commit 793ded5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
11 changes: 8 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assert from 'node:assert'
import fs from 'node:fs'
import path from 'node:path'
import https from 'node:https'
Expand Down Expand Up @@ -28,7 +29,7 @@ function onclose() {

/**
* @param {Error?} error
* @param {import('yauzl').ZipFile?} archive
* @param {import('yauzl').ZipFile} archive
*/
function onopen(error, archive) {
bail(error)
Expand All @@ -52,7 +53,7 @@ function onopen(error, archive) {

/**
* @param {Error?} error
* @param {import('stream').Readable?} rs
* @param {import('stream').Readable} rs
*/
function onreadstream(error, rs) {
bail(error)
Expand All @@ -64,12 +65,16 @@ function onopen(error, archive) {
* @param {Buffer} buf
*/
function onconcat(buf) {
/** @type {Record<string, number>} */
const data = {}
const rows = tsvParse('key\tvalue\n' + String(buf))
let index = -1

while (++index < rows.length) {
data[rows[index].key] = Number.parseInt(rows[index].value, 10)
const row = rows[index]
assert(typeof row.key === 'string', 'expected string key')
assert(typeof row.value === 'string', 'expected string value')
data[row.key] = Number.parseInt(row.value, 10)
}

fs.writeFile(
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"prettier": "^2.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
Expand All @@ -55,8 +54,8 @@
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"generate": "node build",
"build": "tsc --build --clean && tsc --build && type-coverage",
"generate": "node build.js",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
Expand Down
13 changes: 7 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"include": ["*.js"],
"include": ["**/*.js", "index.d.ts"],
"exclude": ["coverage", "node_modules"],
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020"],
"module": "ES2020",
"moduleResolution": "node",
"target": "es2020",
"lib": ["es2020"],
"module": "node16",
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
"skipLibCheck": true,
"strict": true
}
}

0 comments on commit 793ded5

Please sign in to comment.