musicxml-io 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -4
- package/dist/index.mjs +30 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { V as ValidateOptions, a as ValidationResult } from './index-8MkN7sbm.mj
|
|
|
4
4
|
export { ba as AddArticulationOptions, bj as AddBeamOptions, c8 as AddBowingOptions, ch as AddBreathMarkOptions, ck as AddCaesuraOptions, aW as AddChordOptions, c2 as AddChordSymbolOptions, bS as AddCodaOptions, bc as AddDynamicsOptions, bM as AddEndingOptions, bz as AddFermataOptions, c5 as AddFingeringOptions, bU as AddGraceNoteOptions, b$ as AddHarmonyOptions, bX as AddLyricOptions, bT as AddNavigationOptions, cd as AddOctaveShiftOptions, bB as AddOrnamentOptions, b2 as AddPartOptions, bD as AddPedalOptions, bH as AddRehearsalMarkOptions, bI as AddRepeatBarlineOptions, bK as AddRepeatOptions, bR as AddSegnoOptions, b8 as AddSlurOptions, ca as AddStringNumberOptions, bu as AddTempoOptions, bF as AddTextDirectionOptions, bG as AddTextOptions, b6 as AddTieOptions, b1 as AddVoiceOptions, bx as AddWedgeOptions, bl as AutoBeamOptions, bQ as BarStyle, c7 as BowingType, cg as BreathMarkValue, cj as CaesuraValue, bO as ChangeBarlineOptions, bg as ChangeClefOptions, aX as ChangeNoteDurationOptions, bW as ConvertToGraceOptions, br as CopyNotesMultiMeasureOptions, bo as CopyNotesOptions, bh as CreateTupletOptions, bq as CutNotesOptions, b3 as DuplicatePartOptions, b_ as HarmonyKind, bf as InsertClefChangeOptions, aU as InsertNoteOptions, cM as LocalValidateOptions, b0 as LowerAccidentalOptions, cL as MeasureValidationContext, be as ModifyDynamicsOptions, bw as ModifyTempoOptions, b5 as MoveNoteToStaffOptions, bs as MultiMeasureSelection, bn as NoteSelection, cc as OctaveShiftType, aT as OperationErrorCode, aS as OperationResult, bt as PasteNotesMultiMeasureOptions, bp as PasteNotesOptions, a$ as RaiseAccidentalOptions, bb as RemoveArticulationOptions, bk as RemoveBeamOptions, c9 as RemoveBowingOptions, ci as RemoveBreathMarkOptions, cl as RemoveCaesuraOptions, c3 as RemoveChordSymbolOptions, bd as RemoveDynamicsOptions, bN as RemoveEndingOptions, bA as RemoveFermataOptions, c6 as RemoveFingeringOptions, bV as RemoveGraceNoteOptions, c0 as RemoveHarmonyOptions, bY as RemoveLyricOptions, aV as RemoveNoteOptions, cf as RemoveOctaveShiftOptions, bC as RemoveOrnamentOptions, bE as RemovePedalOptions, bJ as RemoveRepeatBarlineOptions, bL as RemoveRepeatOptions, b9 as RemoveSlurOptions, cb as RemoveStringNumberOptions, bv as RemoveTempoOptions, b7 as RemoveTieOptions, bi as RemoveTupletOptions, by as RemoveWedgeOptions, bP as SetBarlineOptions, bm as SetBeamingOptions, aZ as SetNotePitchBySemitoneOptions, aY as SetNotePitchOptions, b4 as SetStavesOptions, a_ as ShiftNotePitchOptions, ce as StopOctaveShiftOptions, c4 as UpdateChordSymbolOptions, c1 as UpdateHarmonyOptions, bZ as UpdateLyricOptions, cH as ValidationError, cJ as ValidationErrorCode, cD as ValidationException, cK as ValidationLevel, cI as ValidationLocation, K as addArticulation, T as addBeam, aH as addBowing, aO as addBreathMark, aQ as addCaesura, b as addChord, j as addChordNote, p as addChordNoteChecked, aC as addChordSymbol, ao as addCoda, ap as addDaCapo, aq as addDalSegno, M as addDynamics, aj as addEnding, a6 as addFermata, ar as addFine, aF as addFingering, at as addGraceNote, az as addHarmony, aw as addLyric, g as addNote, n as addNoteChecked, aL as addOctaveShift, a8 as addOrnament, x as addPart, aa as addPedal, ae as addRehearsalMark, ah as addRepeat, af as addRepeatBarline, an as addSegno, I as addSlur, aJ as addStringNumber, a1 as addTempo, ad as addText, ac as addTextDirection, G as addTie, as as addToCoda, w as addVoice, a4 as addWedge, cG as assertMeasureValid, co as assertValid, W as autoBeam, al as changeBarline, Q as changeClef, C as changeKey, e as changeNoteDuration, D as changeTime, av as convertToGrace, Y as copyNotes, $ as copyNotesMultiMeasure, R as createTuplet, _ as cutNotes, F as deleteMeasure, h as deleteNote, o as deleteNoteChecked, z as duplicatePart, cC as formatLocation, cF as getMeasureContext, P as insertClefChange, E as insertMeasure, i as insertNote, cn as isValid, l as lowerAccidental, O as modifyDynamics, k as modifyNoteDuration, u as modifyNoteDurationChecked, m as modifyNotePitch, q as modifyNotePitchChecked, a3 as modifyTempo, B as moveNoteToStaff, Z as pasteNotes, a0 as pasteNotesMultiMeasure, f as raiseAccidental, L as removeArticulation, U as removeBeam, aI as removeBowing, aP as removeBreathMark, aR as removeCaesura, aD as removeChordSymbol, N as removeDynamics, ak as removeEnding, a7 as removeFermata, aG as removeFingering, au as removeGraceNote, aA as removeHarmony, ax as removeLyric, r as removeNote, aN as removeOctaveShift, a9 as removeOrnament, y as removePart, ab as removePedal, ai as removeRepeat, ag as removeRepeatBarline, J as removeSlur, aK as removeStringNumber, a2 as removeTempo, H as removeTie, S as removeTuplet, a5 as removeWedge, am as setBarline, X as setBeaming, s as setNotePitch, c as setNotePitchBySemitone, A as setStaves, d as shiftNotePitch, aM as stopOctaveShift, t as transpose, v as transposeChecked, aE as updateChordSymbol, aB as updateHarmony, ay as updateLyric, cm as validate, cr as validateBackupForward, ct as validateBeams, cp as validateDivisions, cq as validateMeasureDuration, cE as validateMeasureLocal, cw as validatePartReferences, cx as validatePartStructure, cu as validateSlurs, cB as validateSlursAcrossMeasures, cy as validateStaffStructure, cs as validateTies, cA as validateTiesAcrossMeasures, cv as validateTuplets, cz as validateVoiceStaff } from './index-8MkN7sbm.mjs';
|
|
5
5
|
export { FindNotesFilter, NormalizedPositionOptions, PitchRange, RoundtripMetrics, VoiceFilter, buildVoiceToStaffMap, buildVoiceToStaffMapForPart, countNotes, findBarlines, findDirectionsByType, findNotes, findNotesWithNotation, getAbsolutePosition, getAdjacentNotes, getAllNotes, getAttributesAtMeasure, getBeamGroups, getChordProgression, getChords, getClefChanges, getClefForStaff, getDirections, getDirectionsAtPosition, getDivisions, getDuration, getDynamics, getEffectiveStaff, getEndings, getEntriesAtPosition, getEntriesForStaff, getEntriesInRange, getHarmonies, getHarmonyAtPosition, getKeyChanges, getLyricText, getLyrics, getMeasure, getMeasureByIndex, getMeasureCount, getNextNote, getNormalizedDuration, getNormalizedPosition, getNotesAtPosition, getNotesForStaff, getNotesForVoice, getNotesInRange, getOctaveShifts, getPartById, getPartByIndex, getPartCount, getPartIds, getPartIndex, getPedalMarkings, getPrevNote, getRepeatStructure, getSlurSpans, getStaffRange, getStaveCount, getStaves, getStructuralChanges, getTempoMarkings, getTiedNoteGroups, getTimeChanges, getTupletGroups, getVerseCount, getVerticalSlice, getVoiceLine, getVoiceLineInRange, getVoices, getVoicesForStaff, getWedges, groupByStaff, groupByVoice, hasMultipleStaves, hasNotes, inferStaff, isRestMeasure, iterateEntries, iterateNotes, measureRoundtrip, scoresEqual, withAbsolutePositions } from './query/index.mjs';
|
|
6
6
|
|
|
7
|
-
declare function parse(
|
|
7
|
+
declare function parse(input: string | Uint8Array): Score;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Parse a compressed MusicXML (.mxl) file
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { V as ValidateOptions, a as ValidationResult } from './index-DxLMCMTr.js
|
|
|
4
4
|
export { ba as AddArticulationOptions, bj as AddBeamOptions, c8 as AddBowingOptions, ch as AddBreathMarkOptions, ck as AddCaesuraOptions, aW as AddChordOptions, c2 as AddChordSymbolOptions, bS as AddCodaOptions, bc as AddDynamicsOptions, bM as AddEndingOptions, bz as AddFermataOptions, c5 as AddFingeringOptions, bU as AddGraceNoteOptions, b$ as AddHarmonyOptions, bX as AddLyricOptions, bT as AddNavigationOptions, cd as AddOctaveShiftOptions, bB as AddOrnamentOptions, b2 as AddPartOptions, bD as AddPedalOptions, bH as AddRehearsalMarkOptions, bI as AddRepeatBarlineOptions, bK as AddRepeatOptions, bR as AddSegnoOptions, b8 as AddSlurOptions, ca as AddStringNumberOptions, bu as AddTempoOptions, bF as AddTextDirectionOptions, bG as AddTextOptions, b6 as AddTieOptions, b1 as AddVoiceOptions, bx as AddWedgeOptions, bl as AutoBeamOptions, bQ as BarStyle, c7 as BowingType, cg as BreathMarkValue, cj as CaesuraValue, bO as ChangeBarlineOptions, bg as ChangeClefOptions, aX as ChangeNoteDurationOptions, bW as ConvertToGraceOptions, br as CopyNotesMultiMeasureOptions, bo as CopyNotesOptions, bh as CreateTupletOptions, bq as CutNotesOptions, b3 as DuplicatePartOptions, b_ as HarmonyKind, bf as InsertClefChangeOptions, aU as InsertNoteOptions, cM as LocalValidateOptions, b0 as LowerAccidentalOptions, cL as MeasureValidationContext, be as ModifyDynamicsOptions, bw as ModifyTempoOptions, b5 as MoveNoteToStaffOptions, bs as MultiMeasureSelection, bn as NoteSelection, cc as OctaveShiftType, aT as OperationErrorCode, aS as OperationResult, bt as PasteNotesMultiMeasureOptions, bp as PasteNotesOptions, a$ as RaiseAccidentalOptions, bb as RemoveArticulationOptions, bk as RemoveBeamOptions, c9 as RemoveBowingOptions, ci as RemoveBreathMarkOptions, cl as RemoveCaesuraOptions, c3 as RemoveChordSymbolOptions, bd as RemoveDynamicsOptions, bN as RemoveEndingOptions, bA as RemoveFermataOptions, c6 as RemoveFingeringOptions, bV as RemoveGraceNoteOptions, c0 as RemoveHarmonyOptions, bY as RemoveLyricOptions, aV as RemoveNoteOptions, cf as RemoveOctaveShiftOptions, bC as RemoveOrnamentOptions, bE as RemovePedalOptions, bJ as RemoveRepeatBarlineOptions, bL as RemoveRepeatOptions, b9 as RemoveSlurOptions, cb as RemoveStringNumberOptions, bv as RemoveTempoOptions, b7 as RemoveTieOptions, bi as RemoveTupletOptions, by as RemoveWedgeOptions, bP as SetBarlineOptions, bm as SetBeamingOptions, aZ as SetNotePitchBySemitoneOptions, aY as SetNotePitchOptions, b4 as SetStavesOptions, a_ as ShiftNotePitchOptions, ce as StopOctaveShiftOptions, c4 as UpdateChordSymbolOptions, c1 as UpdateHarmonyOptions, bZ as UpdateLyricOptions, cH as ValidationError, cJ as ValidationErrorCode, cD as ValidationException, cK as ValidationLevel, cI as ValidationLocation, K as addArticulation, T as addBeam, aH as addBowing, aO as addBreathMark, aQ as addCaesura, b as addChord, j as addChordNote, p as addChordNoteChecked, aC as addChordSymbol, ao as addCoda, ap as addDaCapo, aq as addDalSegno, M as addDynamics, aj as addEnding, a6 as addFermata, ar as addFine, aF as addFingering, at as addGraceNote, az as addHarmony, aw as addLyric, g as addNote, n as addNoteChecked, aL as addOctaveShift, a8 as addOrnament, x as addPart, aa as addPedal, ae as addRehearsalMark, ah as addRepeat, af as addRepeatBarline, an as addSegno, I as addSlur, aJ as addStringNumber, a1 as addTempo, ad as addText, ac as addTextDirection, G as addTie, as as addToCoda, w as addVoice, a4 as addWedge, cG as assertMeasureValid, co as assertValid, W as autoBeam, al as changeBarline, Q as changeClef, C as changeKey, e as changeNoteDuration, D as changeTime, av as convertToGrace, Y as copyNotes, $ as copyNotesMultiMeasure, R as createTuplet, _ as cutNotes, F as deleteMeasure, h as deleteNote, o as deleteNoteChecked, z as duplicatePart, cC as formatLocation, cF as getMeasureContext, P as insertClefChange, E as insertMeasure, i as insertNote, cn as isValid, l as lowerAccidental, O as modifyDynamics, k as modifyNoteDuration, u as modifyNoteDurationChecked, m as modifyNotePitch, q as modifyNotePitchChecked, a3 as modifyTempo, B as moveNoteToStaff, Z as pasteNotes, a0 as pasteNotesMultiMeasure, f as raiseAccidental, L as removeArticulation, U as removeBeam, aI as removeBowing, aP as removeBreathMark, aR as removeCaesura, aD as removeChordSymbol, N as removeDynamics, ak as removeEnding, a7 as removeFermata, aG as removeFingering, au as removeGraceNote, aA as removeHarmony, ax as removeLyric, r as removeNote, aN as removeOctaveShift, a9 as removeOrnament, y as removePart, ab as removePedal, ai as removeRepeat, ag as removeRepeatBarline, J as removeSlur, aK as removeStringNumber, a2 as removeTempo, H as removeTie, S as removeTuplet, a5 as removeWedge, am as setBarline, X as setBeaming, s as setNotePitch, c as setNotePitchBySemitone, A as setStaves, d as shiftNotePitch, aM as stopOctaveShift, t as transpose, v as transposeChecked, aE as updateChordSymbol, aB as updateHarmony, ay as updateLyric, cm as validate, cr as validateBackupForward, ct as validateBeams, cp as validateDivisions, cq as validateMeasureDuration, cE as validateMeasureLocal, cw as validatePartReferences, cx as validatePartStructure, cu as validateSlurs, cB as validateSlursAcrossMeasures, cy as validateStaffStructure, cs as validateTies, cA as validateTiesAcrossMeasures, cv as validateTuplets, cz as validateVoiceStaff } from './index-DxLMCMTr.js';
|
|
5
5
|
export { FindNotesFilter, NormalizedPositionOptions, PitchRange, RoundtripMetrics, VoiceFilter, buildVoiceToStaffMap, buildVoiceToStaffMapForPart, countNotes, findBarlines, findDirectionsByType, findNotes, findNotesWithNotation, getAbsolutePosition, getAdjacentNotes, getAllNotes, getAttributesAtMeasure, getBeamGroups, getChordProgression, getChords, getClefChanges, getClefForStaff, getDirections, getDirectionsAtPosition, getDivisions, getDuration, getDynamics, getEffectiveStaff, getEndings, getEntriesAtPosition, getEntriesForStaff, getEntriesInRange, getHarmonies, getHarmonyAtPosition, getKeyChanges, getLyricText, getLyrics, getMeasure, getMeasureByIndex, getMeasureCount, getNextNote, getNormalizedDuration, getNormalizedPosition, getNotesAtPosition, getNotesForStaff, getNotesForVoice, getNotesInRange, getOctaveShifts, getPartById, getPartByIndex, getPartCount, getPartIds, getPartIndex, getPedalMarkings, getPrevNote, getRepeatStructure, getSlurSpans, getStaffRange, getStaveCount, getStaves, getStructuralChanges, getTempoMarkings, getTiedNoteGroups, getTimeChanges, getTupletGroups, getVerseCount, getVerticalSlice, getVoiceLine, getVoiceLineInRange, getVoices, getVoicesForStaff, getWedges, groupByStaff, groupByVoice, hasMultipleStaves, hasNotes, inferStaff, isRestMeasure, iterateEntries, iterateNotes, measureRoundtrip, scoresEqual, withAbsolutePositions } from './query/index.js';
|
|
6
6
|
|
|
7
|
-
declare function parse(
|
|
7
|
+
declare function parse(input: string | Uint8Array): Score;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Parse a compressed MusicXML (.mxl) file
|
package/dist/index.js
CHANGED
|
@@ -243,7 +243,24 @@ function decodeTree(nodes) {
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
var TXML_OPTIONS = { noChildNodes: [] };
|
|
246
|
-
function
|
|
246
|
+
function decodeXmlBytes(data) {
|
|
247
|
+
if (data.length >= 2 && data[0] === 254 && data[1] === 255) {
|
|
248
|
+
return new TextDecoder("utf-16be").decode(data);
|
|
249
|
+
}
|
|
250
|
+
if (data.length >= 2 && data[0] === 255 && data[1] === 254) {
|
|
251
|
+
return new TextDecoder("utf-16le").decode(data);
|
|
252
|
+
}
|
|
253
|
+
return new TextDecoder("utf-8").decode(data);
|
|
254
|
+
}
|
|
255
|
+
function parse(input) {
|
|
256
|
+
let xmlString;
|
|
257
|
+
if (typeof input !== "string") {
|
|
258
|
+
xmlString = decodeXmlBytes(input);
|
|
259
|
+
} else if (input.includes("\0")) {
|
|
260
|
+
xmlString = input.replace(/\x00/g, "");
|
|
261
|
+
} else {
|
|
262
|
+
xmlString = input;
|
|
263
|
+
}
|
|
247
264
|
const cleanedXml = xmlString.replace(/<\?(?!xml\s)[^?]*\?>/g, "");
|
|
248
265
|
const parsed = _txml.parse.call(void 0, cleanedXml, TXML_OPTIONS);
|
|
249
266
|
decodeTree(parsed);
|
|
@@ -2760,6 +2777,15 @@ function parseCompressed(data) {
|
|
|
2760
2777
|
function isCompressed(data) {
|
|
2761
2778
|
return data.length >= 2 && data[0] === 80 && data[1] === 75;
|
|
2762
2779
|
}
|
|
2780
|
+
function decodeXmlBytes2(data) {
|
|
2781
|
+
if (data.length >= 2 && data[0] === 254 && data[1] === 255) {
|
|
2782
|
+
return new TextDecoder("utf-16be").decode(data);
|
|
2783
|
+
}
|
|
2784
|
+
if (data.length >= 2 && data[0] === 255 && data[1] === 254) {
|
|
2785
|
+
return new TextDecoder("utf-16le").decode(data);
|
|
2786
|
+
}
|
|
2787
|
+
return new TextDecoder("utf-8").decode(data);
|
|
2788
|
+
}
|
|
2763
2789
|
function parseAuto(data) {
|
|
2764
2790
|
if (typeof data === "string") {
|
|
2765
2791
|
return parse(data);
|
|
@@ -2767,7 +2793,7 @@ function parseAuto(data) {
|
|
|
2767
2793
|
if (isCompressed(data)) {
|
|
2768
2794
|
return parseCompressed(data);
|
|
2769
2795
|
}
|
|
2770
|
-
const xmlString =
|
|
2796
|
+
const xmlString = decodeXmlBytes2(data);
|
|
2771
2797
|
return parse(xmlString);
|
|
2772
2798
|
}
|
|
2773
2799
|
|
|
@@ -7875,10 +7901,10 @@ async function parseFile(filePath) {
|
|
|
7875
7901
|
}
|
|
7876
7902
|
function decodeBuffer(buffer) {
|
|
7877
7903
|
if (buffer.length >= 2 && buffer[0] === 254 && buffer[1] === 255) {
|
|
7878
|
-
return
|
|
7904
|
+
return new TextDecoder("utf-16be").decode(buffer);
|
|
7879
7905
|
}
|
|
7880
7906
|
if (buffer.length >= 2 && buffer[0] === 255 && buffer[1] === 254) {
|
|
7881
|
-
return
|
|
7907
|
+
return new TextDecoder("utf-16le").decode(buffer);
|
|
7882
7908
|
}
|
|
7883
7909
|
if (buffer.length >= 3 && buffer[0] === 239 && buffer[1] === 187 && buffer[2] === 191) {
|
|
7884
7910
|
return buffer.toString("utf8", 3);
|
package/dist/index.mjs
CHANGED
|
@@ -243,7 +243,24 @@ function decodeTree(nodes) {
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
var TXML_OPTIONS = { noChildNodes: [] };
|
|
246
|
-
function
|
|
246
|
+
function decodeXmlBytes(data) {
|
|
247
|
+
if (data.length >= 2 && data[0] === 254 && data[1] === 255) {
|
|
248
|
+
return new TextDecoder("utf-16be").decode(data);
|
|
249
|
+
}
|
|
250
|
+
if (data.length >= 2 && data[0] === 255 && data[1] === 254) {
|
|
251
|
+
return new TextDecoder("utf-16le").decode(data);
|
|
252
|
+
}
|
|
253
|
+
return new TextDecoder("utf-8").decode(data);
|
|
254
|
+
}
|
|
255
|
+
function parse(input) {
|
|
256
|
+
let xmlString;
|
|
257
|
+
if (typeof input !== "string") {
|
|
258
|
+
xmlString = decodeXmlBytes(input);
|
|
259
|
+
} else if (input.includes("\0")) {
|
|
260
|
+
xmlString = input.replace(/\x00/g, "");
|
|
261
|
+
} else {
|
|
262
|
+
xmlString = input;
|
|
263
|
+
}
|
|
247
264
|
const cleanedXml = xmlString.replace(/<\?(?!xml\s)[^?]*\?>/g, "");
|
|
248
265
|
const parsed = txmlParse(cleanedXml, TXML_OPTIONS);
|
|
249
266
|
decodeTree(parsed);
|
|
@@ -2760,6 +2777,15 @@ function parseCompressed(data) {
|
|
|
2760
2777
|
function isCompressed(data) {
|
|
2761
2778
|
return data.length >= 2 && data[0] === 80 && data[1] === 75;
|
|
2762
2779
|
}
|
|
2780
|
+
function decodeXmlBytes2(data) {
|
|
2781
|
+
if (data.length >= 2 && data[0] === 254 && data[1] === 255) {
|
|
2782
|
+
return new TextDecoder("utf-16be").decode(data);
|
|
2783
|
+
}
|
|
2784
|
+
if (data.length >= 2 && data[0] === 255 && data[1] === 254) {
|
|
2785
|
+
return new TextDecoder("utf-16le").decode(data);
|
|
2786
|
+
}
|
|
2787
|
+
return new TextDecoder("utf-8").decode(data);
|
|
2788
|
+
}
|
|
2763
2789
|
function parseAuto(data) {
|
|
2764
2790
|
if (typeof data === "string") {
|
|
2765
2791
|
return parse(data);
|
|
@@ -2767,7 +2793,7 @@ function parseAuto(data) {
|
|
|
2767
2793
|
if (isCompressed(data)) {
|
|
2768
2794
|
return parseCompressed(data);
|
|
2769
2795
|
}
|
|
2770
|
-
const xmlString =
|
|
2796
|
+
const xmlString = decodeXmlBytes2(data);
|
|
2771
2797
|
return parse(xmlString);
|
|
2772
2798
|
}
|
|
2773
2799
|
|
|
@@ -7875,10 +7901,10 @@ async function parseFile(filePath) {
|
|
|
7875
7901
|
}
|
|
7876
7902
|
function decodeBuffer(buffer) {
|
|
7877
7903
|
if (buffer.length >= 2 && buffer[0] === 254 && buffer[1] === 255) {
|
|
7878
|
-
return
|
|
7904
|
+
return new TextDecoder("utf-16be").decode(buffer);
|
|
7879
7905
|
}
|
|
7880
7906
|
if (buffer.length >= 2 && buffer[0] === 255 && buffer[1] === 254) {
|
|
7881
|
-
return
|
|
7907
|
+
return new TextDecoder("utf-16le").decode(buffer);
|
|
7882
7908
|
}
|
|
7883
7909
|
if (buffer.length >= 3 && buffer[0] === 239 && buffer[1] === 187 && buffer[2] === 191) {
|
|
7884
7910
|
return buffer.toString("utf8", 3);
|