MCPcopy Create free account
hub / github.com/Keyang/node-csvtojson / stripBom

Function stripBom

src/dataClean.ts:2–14  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

1import { ParseRuntime } from "./ParseRuntime";
2function stripBom(string) {
3 if (typeof string !== 'string') {
4 throw new TypeError(`Expected a string, got ${typeof string}`);
5 }
6
7 // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
8 // conversion translates it to FEFF (UTF-16 BOM).
9 if (string.charCodeAt(0) === 0xFEFF) {
10 return string.slice(1);
11 }
12
13 return string;
14}
15
16/**
17 * For each data chunk coming to parser:

Callers 1

prepareDataFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected