diff --git a/build.js b/build.js index 4ae8c86..057dc77 100644 --- a/build.js +++ b/build.js @@ -2,13 +2,14 @@ import fs from 'node:fs' import {emojiEmotion} from 'emoji-emotion' import {emojiToName} from 'gemoji' +/** @type {Record} */ 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( diff --git a/index.js b/index.js index a01eff1..6ffa8fc 100644 --- a/index.js +++ b/index.js @@ -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) { diff --git a/test/index.js b/test/index.js index 9d34f30..1cb5219 100644 --- a/test/index.js +++ b/test/index.js @@ -158,7 +158,13 @@ test('algorithm', function (t) { t.end() }) -// Simple word tokenizer. +/** + * Simple word tokenizer. + * + * @param {string} value + * @returns {Array} + */ function tokenize(value) { - return value.toLowerCase().match(/\S+/g) + const match = value.toLowerCase().match(/\S+/g) + return match ? [...match] : [] } diff --git a/tsconfig.json b/tsconfig.json index be08abe..016d1f4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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" } }