Commit c811aefa authored by Aral Balkan's avatar Aral Balkan
Browse files

Update all remaining examples to ESM format

parent 03a74c22
const JSDF = require('../../lib/JSDF')
const faker = require('faker')
import JSDF from '../../lib/JSDF.js'
import faker from 'faker'
const card = faker.helpers.createCard()
......@@ -35,8 +35,8 @@ console.timeLog('serialise custom objects')
console.log(serialisedPeople)
let folks
eval(serialisedPeople)
folks[1].introduceYourself()
console.log('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
......
......@@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
......
const fs = require('fs')
const JSDB = require('../..')
import fs from 'fs'
import JSDB from '../../index.js'
const db = JSDB.open('db')
......
<script src="db/episodes.js"></script>
<h1>Lovecraft Country</h1>
<p>Episodes and ratings from <a href='https://www.imdb.com/title/tt6905686/episodes?season=1'>IMDB</a>:</p>
<ul>
<script>
<ul id='episodes'>
<script type="module">
import { _ as episodes } from '/db/episodes.js'
const episodesList = document.getElementById('episodes')
episodes.forEach(episode => {
document.write(`<li><strong>${episode.title}</strong> ⭐ ${episode.rating}</li>`)
const li = document.createElement('li')
li.innerHTML = `<strong>${episode.title}</strong> ⭐ ${episode.rating}`
episodesList.appendChild(li)
})
</script>
</ul>
const JSDB = require('../..')
import JSDB from '../../index.js'
// Open your database (creating it if it doesn’t exist)
// It will be stored in a directory called “db”.
......
const JSDB = require('../..')
import JSDB from '../../index.js'
const db = JSDB.open('db')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment