Skip to content

Commit

Permalink
fix: build files and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
bent10 committed Jun 23, 2022
1 parent 933c804 commit 176a702
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.17
node-version: 12.20
- run: npm ci
- run: npm run lint
- run: npm run build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
fail-fast: false
matrix:
node-version:
- 18
- 16
- 14
- 14.14
- 12.20
os:
- ubuntu-latest
- windows-latest
Expand Down
14 changes: 14 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"test": ".*.ts$",
"jsc": {
"parser": {
"syntax": "typescript"
},
"target": "es2019",
"externalHelpers": true
},
"module": {
"type": "es6"
}
}
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"matching"
],
"engines": {
"node": ">=v12.22.12"
"node": "^12.20 || ^14.14 || >=16"
},
"type": "module",
"main": "dist/index.js",
"exports": "./dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist",
Expand All @@ -41,15 +41,15 @@
"start": "npm run build && npm run watch",
"watch": "chokidar \"src/*.ts\" -c \"npm run build\"",
"lint": "tsc --noEmit && eslint \"./src\" --ext \".ts\" --cache --cache-location \"node_modules/.cache/.eslintcache\"",
"build": "swc \"./src\" -d \"dist\" && tsc \"src/index.ts\" -d --emitDeclarationOnly --outDir \"dist\"",
"build": "swc \"./src\" -d \"dist\" && tsc -d --emitDeclarationOnly",
"test": "ava --verbose",
"coverage": "c8 -r lcov -r text npm test"
},
"dependencies": {
"leven": "^4.0.0"
},
"devDependencies": {
"doogu": "^2.1.2"
"doogu": "^2.1.5"
},
"config": {
"commitizen": {
Expand Down
54 changes: 35 additions & 19 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ Finds similar word(s) in a list of words.

#### Parameters

| Name | Type | Description |
| :----------- | :------- | :------------------------------------ |
| `word` | string | The word to find similar words for. |
| `candidates` | string[] | An array of words to compare against. |
| `options` | Options | Options for the function. |
| Name | Type | Description |
| :----------- | :---------------------------- | :------------------------------------ |
| `word` | string | The word to find similar words for. |
| `candidates` | string[] | An array of words to compare against. |
| `options` | [Options](#interface-options) | Options for the function. |

#### Returns

Expand All @@ -54,33 +54,49 @@ An array of similar words.

Suggests similar words in a list of words.

```js
const suggetion = didYouMean('foos', ['bar', 'baz', 'foo'], {
prefix: '--'
})
console.log(suggetion)
// => 'Did you mean "--foo"?'
```

#### Parameters

| Name | Type | Description |
| :----------- | :------- | :------------------------------------ |
| `word` | string | The word to find similar words for. |
| `candidates` | string[] | An array of words to compare against. |
| `options` | Options | Options for the function. |
| Name | Type | Description |
| :----------- | :---------------------------- | :------------------------------------ |
| `word` | string | The word to find similar words for. |
| `candidates` | string[] | An array of words to compare against. |
| `options` | [Options](#interface-options) | Options for the function. |

#### Returns

string

A string of suggested words.

## Type aliases
---

### Interface: Options

#### maxScore

`Optional` **maxScore**: `number`

Maximum levenshtein distance threshold. **`default`** 3

#### criteria

`Optional` **criteria**: `number`

### Options
The similarity threshold, a number between 0 and 1. **`default`** 0.5

Ƭ **Options**: `Object`
#### prefix

#### Type declaration
`Optional` **prefix**: `string`

| Name | Type | Description |
| :---------- | :----- | :-------------------------------------------------------------------- |
| `maxScore?` | number | Maximum levenshtein distance threshold. **`default`** 3 |
| `criteria?` | number | The similarity threshold, a number between 0 and 1. **`default`** 0.5 |
| `prefix?` | string | A string to prepend to the suggested word. **`default`** '' |
A string to prepend to the suggested word. **`default`** ''

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava'
import { findSimilar, didYouMean } from '../src/index.js'
import { findSimilar, didYouMean } from '../dist/index.js'

test('singgle suggestions', t => {
const suggestions = didYouMean('foos', ['bar', 'baz', 'foo'])
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extends": "doogu/config/tsconfig.json",

"include": ["src", "test"]
"compilerOptions": {
"outDir": "dist"
},

"include": ["src"]
}

0 comments on commit 176a702

Please sign in to comment.