Skip to content

Commit 1440c23

Browse files
committed
fix: missing module declaration, dependencies and some typing
1 parent 756162f commit 1440c23

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

pnpm-lock.yaml

Lines changed: 13 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
declare module 'image-to-ascii-art' {
2+
interface ConfigInterface {
3+
// the integer of pixels drawn on the canvas.
4+
// it sets bigger,the generated ascii art will be more detailed.
5+
// it has two type to set:
6+
// 1. (0, 1] decimal.result is that this number multiplied by the number of pixels in the original image
7+
// 2. An integer greater than 1.
8+
drawWidth?: number;
9+
drawHeight?: number;
10+
// the integer that pick one for every how many pixels.
11+
// it must be an integer greater than 0.
12+
pickDensityHorizontal?: number;
13+
pickDensityVertical?: number;
14+
// set the char of every grey range.
15+
greyRangeChar?: GreyRangeChar[];
16+
// if a grey value can't match one of the 'greyRangeChar' config,use this char.
17+
defaultGreyChar?: string;
18+
}
19+
20+
class ImageToAsciiArt {
21+
constructor({ canvas, config = {} }: { canvas?: HTMLCanvasElement; config?: ConfigInterface } = {})
22+
public convert(image: string | HTMLImageElement): Promise<string>
23+
public destroy(): void
24+
}
25+
}

src/utils/ascii-lang-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
function escapeXml(unsafe: string) {
2-
return unsafe.replace(/[<>&'"]/g, (c: string | undefined) => {
2+
return unsafe.replace(/[<>&'"]/g, (c: string) => {
33
switch (c) {
44
case '<': return '&lt;';
55
case '>': return '&gt;';
66
case '&': return '&amp;';
77
case '\'': return '&apos;';
88
case '"': return '&quot;';
99
}
10+
return c;
1011
});
1112
}
1213

0 commit comments

Comments
 (0)