Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Js

Idiom #127 Source code inclusion

Import the source code for the function foo body from a file "foobody.txt".

import { readFile } from 'fs/promises';
const foo = new Function(await readFile('foobody.txt'));
void foo()
{
#include "foobody.txt"
}

Same as C++

New implementation...
< >
MLKo