Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 7, 2021
1 parent b25cbfb commit 3cce987
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
*.d.ts
*.log
coverage/
node_modules/
*.d.ts
*.log
.DS_Store
yarn.lock
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {collapseWhiteSpace} from 'collapse-white-space'
* @typedef {Object.<string, number>} TrigramDictionary
*/

var own = {}.hasOwnProperty
const own = {}.hasOwnProperty

/**
* Clean `value`.
Expand Down Expand Up @@ -45,10 +45,10 @@ export function trigrams(value) {
* @returns {TrigramDictionary}
*/
export function asDictionary(value) {
var values = trigrams(value)
const values = trigrams(value)
/** @type {TrigramDictionary} */
var dictionary = {}
var index = -1
const dictionary = {}
let index = -1

while (++index < values.length) {
if (own.call(dictionary, values[index])) {
Expand All @@ -68,11 +68,11 @@ export function asDictionary(value) {
* @returns {TrigramTuples}
*/
export function asTuples(value) {
var dictionary = asDictionary(value)
const dictionary = asDictionary(value)
/** @type {TrigramTuples} */
var tuples = []
const tuples = []
/** @type {string} */
var trigram
let trigram

for (trigram in dictionary) {
if (own.call(dictionary, trigram)) {
Expand All @@ -93,8 +93,8 @@ export function asTuples(value) {
*/
export function tuplesAsDictionary(tuples) {
/** @type {TrigramDictionary} */
var dictionary = {}
var index = -1
const dictionary = {}
let index = -1

while (++index < tuples.length) {
dictionary[tuples[index][0]] = tuples[index][1]
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@
"trailingComma": "none"
},
"xo": {
"prettier": true,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},
"remarkConfig": {
"plugins": [
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from './index.js'

test('.clean', function (t) {
var ignore = '!"#$%&\'()*+,-./0123456789:;<=>?@'
var index = -1
const ignore = '!"#$%&\'()*+,-./0123456789:;<=>?@'
let index = -1

t.equal(typeof clean('test'), 'string', 'should return a string')
t.equal(clean(), '', 'should accept a missing value')
Expand Down

0 comments on commit 3cce987

Please sign in to comment.