SamJS is an Open Source in-real-time JavaScript runner for testing and prototyping your JS code.
📚 Table of contents
- Instant run the code when it's modificated
- Async functions like
fetch
or your custom ones - Import libraries using the
require
method - Code autocomplanation while you type
You can import modules in your program by using the async method require
:
require(<url>) -> Promise(<library>)
An example importing random-words
:
const rw = await require('https://esm.sh/[email protected]')
console.log(rw['wordList'])
Note
You can only import libraries wich use ECMAScript modules
You can also use the method fetch
in SamJS, for using it correctly, follow this structure:
fetch(<url>)
.then(res => <action>)
Otherwise, you will get an empty object ({}
) as the response.
An example calling the pokeapi:
fetch('https://pokeapi.co/api/v2/pokemon/ditto')
.then(res => res.json())
.then(response => console.log(response.name)) // Prints 'ditto'
SamJS supports four different print methods:
console.log('This is a log')
console.info('This is some info')
console.warning('This is a warning')
console.error('This is an error')
The example in the app:
You can switch between dark and light modes by pressing the theme button: