Skip to content

Commit 087a4cd

Browse files
authored
Merge pull request #8 from cto-af/deno
Support deno better by ensuring node built-ins are imported with node:
2 parents 4c9b70f + ae58e2f commit 087a4cd

File tree

4 files changed

+102
-58
lines changed

4 files changed

+102
-58
lines changed

lib/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ export class StringWidth {
5151
/**
5252
* Create a StringWidth instance.
5353
*
54-
* @param {StringWidthOptions} opts
54+
* @param {StringWidthOptions?} opts
5555
*/
56-
constructor(opts) {
56+
constructor(opts = {}) {
5757
/**
5858
* @type {Required<StringWidthOptions>}
5959
*/
@@ -66,10 +66,10 @@ export class StringWidth {
6666
this.#graphemes = new Intl.Segmenter(options.locale, {
6767
granularity: 'grapheme',
6868
});
69-
if (typeof opts.isCJK === 'boolean') {
70-
this.#isCJK = opts.isCJK;
69+
if (typeof opts?.isCJK === 'boolean') {
70+
this.#isCJK = options.isCJK;
7171
} else {
72-
const loc = new Intl.Locale(this.locale).maximize();
72+
const loc = new Intl.Locale(options.locale).maximize();
7373
// Script is never undefined after going through Segmenter
7474
this.#isCJK = ['Hans', 'Hant', 'Kore', 'Jpan']
7575
.includes(/** @type {string} */ (loc.script));

lib/widths.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {Buffer} from 'buffer';
1+
import {Buffer} from 'node:buffer';
22
import {UnicodeTrie} from '@cto.af/unicode-trie';
33

44
export const version = '15.1.0';
55
export const inputFileDate = new Date('2023-08-07T15:21:24.000Z');
6-
export const generatedDate = new Date('2023-10-31T21:48:03.856Z');
6+
export const generatedDate = new Date('2023-11-24T19:49:21.719Z');
77
export const Width = new UnicodeTrie(Buffer.from(
88
`AAARAAAAAADdBAAAGx95MJ4Jts2CbayTN4fNM46QZNYkOuxSYVLDW/NhMQCg4RGrqw3eF0CA
99
3zf3r75iPxuzBfeNQFCmQlKKIDQq1Gne7H2YLdHxPd+ZqkpV6atnkkK2iBHgy+757zT5Pgge

package-lock.json

+91-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
"license": "MIT",
2525
"devDependencies": {
2626
"@cto.af/eslint-config": "3.0.2",
27-
"@types/node": "20.8.10",
27+
"@types/node": "20.10.0",
2828
"c8": "8.0.1",
29-
"eslint": "8.52.0",
29+
"eslint": "8.54.0",
3030
"mocha": "10.2.0",
31-
"typescript": "5.2.2"
31+
"typescript": "5.3.2"
3232
},
3333
"dependencies": {
34-
"@cto.af/unicode-trie": "1.2.2",
34+
"@cto.af/unicode-trie": "1.2.3",
3535
"emoji-regex": "10.3.0"
3636
},
3737
"engines": {

0 commit comments

Comments
 (0)