GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode/packages/opencode/src/util/bom.ts at dev · ngbrown/opencode Expand file tree/ Copy pathbom.tsMore file actions 27 lines (22 loc) · 949 Bytes / Copy pathbom.tsFile metadata and controls27 lines (22 loc) · 949 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 import { Effect } from "effect" import { FSUtil } from "@opencode-ai/core/fs-util" const BOM_CODE = 0xfeff const BOM = String.fromCharCode(BOM_CODE) export function split(text: string) { if (text.charCodeAt(0) !== BOM_CODE) return { bom: false, text } return { bom: true, text: text.slice(1) } } export function join(text: string, bom: boolean) { const stripped = split(text).text if (!bom) return stripped return BOM + stripped } export const readFile = Effect.fn("Bom.readFile")(function* (fs: FSUtil.Interface, filePath: string) { return split(new TextDecoder("utf-8", { ignoreBOM: true }).decode(yield* fs.readFile(filePath))) }) export const syncFile = Effect.fn("Bom.syncFile")(function* (fs: FSUtil.Interface, filePath: string, bom: boolean) { const current = yield* readFile(fs, filePath) if (current.bom === bom) return current.text yield* fs.writeWithDirs(filePath, join(current.text, bom)) return current.text }) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |