mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 00:25:34 +08:00
* Make native installs portable and smaller - Support glibc 2.34 with portable compiler binaries and static LLVM helpers. - Bundle the host runtime and discover optional cross-target packs from project dependencies. - Add application build benchmarks covering latency, executable size, and memory. * Keep bootstrap tools available in Sandbox validation - Isolate Zig for native compiler bootstrap and glibc entropy contracts. - Preserve the existing toolchain scope for cache and corpus tests. * Fix portable compiler bootstrap linking - Keep native support objects compatible with the destination host linker. - Resolve installed targets using the host declared by the toolchain manifest.
18 lines
738 B
TypeScript
18 lines
738 B
TypeScript
import type { Product } from "./types.ts";
|
|
import { normalize } from "./normalize.ts";
|
|
import { valid } from "./validate.ts";
|
|
export function parse(source: string): Product[] {
|
|
const products: Product[] = [];
|
|
let lineNumber = 0;
|
|
for (const line of source.split("\n")) {
|
|
lineNumber++;
|
|
if (line.trim() === "") continue;
|
|
const fields = line.split("\t");
|
|
if (fields.length !== 5) throw new Error("invalid inventory line " + lineNumber);
|
|
const product = { sku: fields[0]!, category: normalize(fields[1]!), name: fields[2]!, quantity: Number(fields[3]), price: Number(fields[4]) };
|
|
if (!valid(product)) throw new Error("invalid product on line " + lineNumber);
|
|
products.push(product);
|
|
}
|
|
return products;
|
|
}
|