Skip to content

Commit

Permalink
Change to use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 3, 2023
1 parent ecaa189 commit 844812c
Show file tree
Hide file tree
Showing 283 changed files with 905 additions and 7,555 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ archive/
source/
node_modules/
*.d.ts
*.map
.DS_Store
.source
.spdx
Expand Down
28 changes: 0 additions & 28 deletions dictionaries/bg/index.d.ts

This file was deleted.

58 changes: 6 additions & 52 deletions dictionaries/bg/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/**
* @callback Callback
* Callback.
* @param {Error | undefined} error
* Error.
* @param {Dictionary | undefined} [dictionary]
* Dictionary.
*
* @typedef Dictionary
* Hunspell dictionary.
* @property {Uint8Array} aff
Expand All @@ -14,51 +7,12 @@
* Data for the dictionary file (contains words and flags applying to those words).
*/

const fs = require('fs')
const path = require('path')
import fs from 'node:fs/promises'

module.exports = load
const aff = await fs.readFile(new URL('index.aff', import.meta.url))
const dic = await fs.readFile(new URL('index.dic', import.meta.url))

/**
* @param {Callback} callback
* Callback.
* @returns {undefined}
* Nothing.
*/
function load(callback) {
/** @type {Dictionary} */
// @ts-expect-error: filled later.
let result = {}
let pos = -1
/** @type {Error | undefined} */
let exception

one('aff')
one('dic')

/**
* @param {'aff' | 'dic'} name
* Name.
* @returns {undefined}
* Nothing.
*/
function one(name) {
fs.readFile(path.join(__dirname, 'index.' + name), function (error, doc) {
pos++
exception = exception || error || undefined
result[name] = doc

if (pos) {
if (exception) {
callback(exception)
} else {
callback(undefined, result)
}
/** @type {Dictionary} */
const dictionary = {aff, dic}

exception = undefined
// @ts-expect-error: free memory.
result = undefined
}
})
}
}
export default dictionary
4 changes: 3 additions & 1 deletion dictionaries/bg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
"Titus Wormer <[email protected]> (https://wooorm.com)",
"Thomas Beverley <[email protected]>"
],
"type": "module",
"files": [
"index.aff",
"index.d.ts",
"index.dic",
"index.js"
"index.js",
"index.map"
]
}
28 changes: 0 additions & 28 deletions dictionaries/br/index.d.ts

This file was deleted.

58 changes: 6 additions & 52 deletions dictionaries/br/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/**
* @callback Callback
* Callback.
* @param {Error | undefined} error
* Error.
* @param {Dictionary | undefined} [dictionary]
* Dictionary.
*
* @typedef Dictionary
* Hunspell dictionary.
* @property {Uint8Array} aff
Expand All @@ -14,51 +7,12 @@
* Data for the dictionary file (contains words and flags applying to those words).
*/

const fs = require('fs')
const path = require('path')
import fs from 'node:fs/promises'

module.exports = load
const aff = await fs.readFile(new URL('index.aff', import.meta.url))
const dic = await fs.readFile(new URL('index.dic', import.meta.url))

/**
* @param {Callback} callback
* Callback.
* @returns {undefined}
* Nothing.
*/
function load(callback) {
/** @type {Dictionary} */
// @ts-expect-error: filled later.
let result = {}
let pos = -1
/** @type {Error | undefined} */
let exception

one('aff')
one('dic')

/**
* @param {'aff' | 'dic'} name
* Name.
* @returns {undefined}
* Nothing.
*/
function one(name) {
fs.readFile(path.join(__dirname, 'index.' + name), function (error, doc) {
pos++
exception = exception || error || undefined
result[name] = doc

if (pos) {
if (exception) {
callback(exception)
} else {
callback(undefined, result)
}
/** @type {Dictionary} */
const dictionary = {aff, dic}

exception = undefined
// @ts-expect-error: free memory.
result = undefined
}
})
}
}
export default dictionary
4 changes: 3 additions & 1 deletion dictionaries/br/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
"Titus Wormer <[email protected]> (https://wooorm.com)",
"Thomas Beverley <[email protected]>"
],
"type": "module",
"files": [
"index.aff",
"index.d.ts",
"index.dic",
"index.js"
"index.js",
"index.map"
]
}
28 changes: 0 additions & 28 deletions dictionaries/ca-valencia/index.d.ts

This file was deleted.

58 changes: 6 additions & 52 deletions dictionaries/ca-valencia/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/**
* @callback Callback
* Callback.
* @param {Error | undefined} error
* Error.
* @param {Dictionary | undefined} [dictionary]
* Dictionary.
*
* @typedef Dictionary
* Hunspell dictionary.
* @property {Uint8Array} aff
Expand All @@ -14,51 +7,12 @@
* Data for the dictionary file (contains words and flags applying to those words).
*/

const fs = require('fs')
const path = require('path')
import fs from 'node:fs/promises'

module.exports = load
const aff = await fs.readFile(new URL('index.aff', import.meta.url))
const dic = await fs.readFile(new URL('index.dic', import.meta.url))

/**
* @param {Callback} callback
* Callback.
* @returns {undefined}
* Nothing.
*/
function load(callback) {
/** @type {Dictionary} */
// @ts-expect-error: filled later.
let result = {}
let pos = -1
/** @type {Error | undefined} */
let exception

one('aff')
one('dic')

/**
* @param {'aff' | 'dic'} name
* Name.
* @returns {undefined}
* Nothing.
*/
function one(name) {
fs.readFile(path.join(__dirname, 'index.' + name), function (error, doc) {
pos++
exception = exception || error || undefined
result[name] = doc

if (pos) {
if (exception) {
callback(exception)
} else {
callback(undefined, result)
}
/** @type {Dictionary} */
const dictionary = {aff, dic}

exception = undefined
// @ts-expect-error: free memory.
result = undefined
}
})
}
}
export default dictionary
4 changes: 3 additions & 1 deletion dictionaries/ca-valencia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
"Titus Wormer <[email protected]> (https://wooorm.com)",
"Thomas Beverley <[email protected]>"
],
"type": "module",
"files": [
"index.aff",
"index.d.ts",
"index.dic",
"index.js"
"index.js",
"index.map"
]
}
28 changes: 0 additions & 28 deletions dictionaries/ca/index.d.ts

This file was deleted.

Loading

0 comments on commit 844812c

Please sign in to comment.