Skip to content

Commit

Permalink
Merge pull request #171 from ianlauyin/punycode
Browse files Browse the repository at this point in the history
Replace node:punycode with punycode.js due to deprecate
  • Loading branch information
nfroidure authored Sep 7, 2024
2 parents 6431851 + ba9d4e4 commit cd86ee5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"commander": "^12.1.0",
"debug": "^4.3.6",
"glob": "^11.0.0",
"punycode": "^2.3.1",
"sax": "^1.4.1",
"svg-pathdata": "^7.0.0",
"transformation-matrix-js": "^2.7.6",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ucs2 } from 'punycode';
import punycode from 'punycode/punycode.js';
import { Transform } from 'stream';
import Sax from 'sax';
import { SVGPathData } from 'svg-pathdata';
Expand Down Expand Up @@ -562,7 +562,7 @@ export class SVGIcons2SVGFontStream extends Transform {
delete glyph.paths;
const d = glyphPath.round(this._options.round).encode();
glyph.unicode.forEach((unicode, i) => {
const unicodeStr = ucs2
const unicodeStr = punycode.ucs2
.decode(unicode)
.map((point) => '&#x' + point.toString(16).toUpperCase() + ';')
.join('');
Expand Down
4 changes: 2 additions & 2 deletions src/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Readable } from 'node:stream';
import fs from 'node:fs';
import { mkdir } from 'node:fs/promises';
import { join } from 'node:path';
import { ucs2 as ucs2 } from 'punycode';
import punycode from 'punycode/punycode.js';

import { SVGIcons2SVGFontStream } from '../index.js';
import { SVGIconsDirStream, type SVGIconStream } from '../iconsdir.js';
Expand Down Expand Up @@ -566,7 +566,7 @@ describe('Passing code points', () => {

svgIconStream.metadata = {
name: 'account',
unicode: [ucs2.encode([0x1f63a])],
unicode: [punycode.ucs2.encode([0x1f63a])],
};

const promise = bufferStream(svgFontStream);
Expand Down

0 comments on commit cd86ee5

Please sign in to comment.