Skip to content

Commit 4dfd0af

Browse files
committed
Remove 'stream-bom' and 'strip-bom-buf' dependencies
1 parent 33a00b2 commit 4dfd0af

File tree

3 files changed

+6
-53
lines changed

3 files changed

+6
-53
lines changed

package-lock.json

Lines changed: 0 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@
111111
"rxjs": "6.6.7",
112112
"semver": "7.5.4",
113113
"stream": "0.0.2",
114-
"strip-bom": "5.0.0",
115-
"strip-bom-buf": "2.0.0",
116114
"tmp": "0.2.4",
117115
"vscode-html-languageservice": "^5.3.1",
118116
"vscode-jsonrpc": "9.0.0-next.8",

src/utils/removeBom.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import removeBomBuffer from 'strip-bom-buf';
7-
import removeBomString from 'strip-bom';
6+
import * as NodeBuffer from 'node:buffer';
87

98
export function removeBOMFromBuffer(buffer: Buffer): Buffer {
10-
return removeBomBuffer(buffer);
9+
return buffer[0] === 0xef && buffer[1] === 0xbb && buffer[2] === 0xbf && NodeBuffer.isUtf8(buffer)
10+
? buffer.subarray(3)
11+
: buffer;
1112
}
1213

1314
export function removeBOMFromString(line: string): string {
14-
return removeBomString(line.trim());
15+
line = line.trim();
16+
return line.charCodeAt(0) === 0xfeff ? line.slice(1) : line;
1517
}

0 commit comments

Comments
 (0)