Skip to main content
Go to Latest
File
import { NestedInteger } from "../mini-parser/NestedInteger.ts";import { NestedArray } from "./NestedArray.ts";
export function NestedIntegerFrom(array: NestedArray) { const nestedInteger = new NestedInteger(); for (const value of array) { if (typeof value === "number") { nestedInteger.add(new NestedInteger(value)); } else if (Array.isArray(value)) { nestedInteger.add(NestedIntegerFrom(value)); } else throw Error("invalid input type"); } return nestedInteger;}