Skip to main content

Run serverless functions

Typegraphs allow us to define and execute at different places to accomplish myriad of tasks:

Loading...

Here's what fib.ts looks like:

// Copyright Metatype OÜ, licensed under the Elastic License 2.0.
// SPDX-License-Identifier: Elastic-2.0

const CACHE = [1, 1];
const MAX_CACHE_SIZE = 1000;

export default function fib({ size }: { size: number }) {
if (size > MAX_CACHE_SIZE) {
throw new Error(`unsupported size ${size} > ${MAX_CACHE_SIZE}`);
}
let i = CACHE.length;
while (i++ < size) {
CACHE.push(CACHE[i - 2] + CACHE[i - 3]);
}
return CACHE.slice(0, size);
}