Skip to content

Commit b5e8784

Browse files
authored
Remove 'stream-bom' and 'strip-bom-buf' dependencies (#8542)
2 parents b25fcbf + e00e50a commit b5e8784

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
@@ -109,8 +109,6 @@
109109
"ps-list": "7.2.0",
110110
"rxjs": "6.6.7",
111111
"semver": "7.5.4",
112-
"strip-bom": "5.0.0",
113-
"strip-bom-buf": "2.0.0",
114112
"vscode-html-languageservice": "^5.3.1",
115113
"vscode-jsonrpc": "9.0.0-next.8",
116114
"vscode-languageclient": "10.0.0-next.15",

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)