Skip to content

Commit

Permalink
Add strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 7, 2022
1 parent 170e655 commit 681392a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
7 changes: 4 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import fs from 'node:fs'
import {emojiEmotion} from 'emoji-emotion'
import {emojiToName} from 'gemoji'

/** @type {Record<string, number>} */
const data = {}
let index = -1

while (++index < emojiEmotion.length) {
data[emojiEmotion[index].emoji] = emojiEmotion[index].polarity
data[':' + emojiToName[emojiEmotion[index].emoji] + ':'] =
emojiEmotion[index].polarity
const info = emojiEmotion[index]
data[info.emoji] = info.polarity
data[':' + emojiToName[info.emoji] + ':'] = info.polarity
}

fs.writeFileSync(
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function inject(values) {
* Get the polarity of a word.
*
* @param {string} value
* @param {Inject} inject
* @param {Inject} [inject]
* @returns {number}
*/
function getPolarity(value, inject) {
Expand Down
10 changes: 8 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ test('algorithm', function (t) {
t.end()
})

// Simple word tokenizer.
/**
* Simple word tokenizer.
*
* @param {string} value
* @returns {Array<string>}
*/
function tokenize(value) {
return value.toLowerCase().match(/\S+/g)
const match = value.toLowerCase().match(/\S+/g)
return match ? [...match] : []
}
18 changes: 10 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"include": ["*.js"],
"include": ["**/**.js"],
"exclude": ["coverage", "node_modules"],
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020"],
"module": "ES2020",
"moduleResolution": "node",
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es2020"],
"module": "node16",
"newLine": "lf",
"skipLibCheck": true,
"strict": true,
"target": "es2020"
}
}

0 comments on commit 681392a

Please sign in to comment.