UNPKG

tio.js

Version:

A small TypeScript library that lets you evaluate code in a sandboxed environment everywhere with TryItOnline.

13 lines (12 loc) 412 B
import { TioHttpError } from './error.js'; export function validStringArray(arr) { return (Array.isArray(arr) && arr.every(elem => typeof elem === 'string' && elem.length > 0)); } export async function requestText(path) { const response = await fetch(`https://tio.run${path}`); if (response.status >= 400) { throw new TioHttpError(response); } return await response.text(); }