Skip to content

Commit

Permalink
Add JSDoc based types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Mar 8, 2021
1 parent 78e42e4 commit 24ee798
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
.DS_Store
*.d.ts
*.log
coverage/
node_modules/
Expand Down
7 changes: 6 additions & 1 deletion index.js
@@ -1,4 +1,9 @@
// `collapse(' \t\nbar \nbaz\t') // ' bar baz '`
/**
* Collapse whitespace to a single space.
*
* @param {string} value
* @returns {string}
*/
export function collapseWhiteSpace(value) {
return String(value).replace(/\s+/g, ' ')
}
10 changes: 9 additions & 1 deletion package.json
Expand Up @@ -21,22 +21,30 @@
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"devDependencies": {
"@types/tape": "^4.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"typescript": "^4.0.0",
"xo": "^0.38.0"
},
"scripts": {
"prepublishOnly": "npm run build",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"prebuild": "rimraf \"*.d.ts\"",
"build": "tsc",
"test-api": "node test",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run format && npm run test-coverage"
"test": "npm run format && npm run build && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Expand Up @@ -33,7 +33,8 @@ There is no default export.

### `collapseWhiteSpace(value)`

Replace multiple whitespace characters in value with a single space.
Replace multiple whitespace characters in `value` (`string`) with a single
space.

## License

Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
@@ -0,0 +1,16 @@
{
"files": ["index.js"],
"include": ["*.js"],
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020"],
"module": "ES2020",
"moduleResolution": "node",
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
}
}

0 comments on commit 24ee798

Please sign in to comment.