Service | SSL | status | Response Type | Allowed methods | Allowed headers |
---|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { watch } from 'node:fs/promises' | |
import { Worker } from 'node:worker_threads' | |
let worker = new Worker('./app.js') | |
async function reloadOnChange (dir) { | |
const watcher = watch(dir, { recursive: true }) | |
for await (const change of watcher) { | |
if (change.filename.endsWith('.js')) { | |
worker.terminate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const blob = new Blob(['123']) | |
const xhr = new XMLHttpRequest() | |
const url = URL.createObjectURL(blob) | |
// required if you need to read binary data: | |
xhr.overrideMimeType('text/plain; charset=x-user-defined') | |
xhr.open('GET', url, false) | |
xhr.send() | |
const uint8 = Uint8Array.from(xhr.response, c => c.charCodeAt(0)) |
This is a response to https://gist.github.com/joepie91/bca2fda868c1e8b2c2caf76af7dfcad3?permalink_comment_id=4767875#gistcomment-4767875
if you are so sure about using 'import' from common js then send some code samples - maybe it will help someone else.
Sure @cybafelo, i can give you 3 example (from easy to more adv)
i'm going to create a basic hello world example that uses express
(cjs) and node-fetch
(esm-only)
here is what my package.json looks like:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Read a stream into same underlying ArrayBuffer of a fixed size. | |
* And yield a new Uint8Array view of the same underlying buffer. | |
* @param {ReadableStreamBYOBReader} reader | |
* @param {number} chunkSize | |
*/ | |
async function* blockReader(reader, chunkSize) { | |
let offset = 0; | |
let buffer = new ArrayBuffer(chunkSize) | |
let done, view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pc1 = new RTCPeerConnection(), | |
pc2 = new RTCPeerConnection(); | |
var addCandidate = (pc, can) => can && pc.addIceCandidate(can).catch(console.error); | |
pc1.onicecandidate = e => { addCandidate(pc2, e.candidate); }; | |
pc2.onicecandidate = e => { addCandidate(pc1, e.candidate); }; | |
pc1.oniceconnectionstatechange = e => console.log("pc1 iceConnState:", pc1.iceConnectionState); | |
pc2.oniceconnectionstatechange = e => console.log("pc2 iceConnState:", pc2.iceConnectionState); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We allocate a file with the size of the downloaded file so we can | |
// append chunks randomly to diffrent position as we download the file | |
function allocateDisk(size, callback){ | |
fss.cwd.getFile(prompt("Filename","movie.mp4"), {create: true}, (fileEntry) => { | |
fileEntry.createWriter((writer) => { | |
var blob = new Blob([new ArrayBuffer(1.049e+8)]) | |
writer.onerror = (err) => { |
- ⎋ (escape):
U+238B
- ⇥ (tab):
U+21E5
- ⇪ (caps lock):
U+21EA
- ⇧ (shift):
U+21E7
- ⌃ (control):
U+2303
- ⌥ (option):
U+2325
- (Apple):
U+F8FF
(in some Apple-provided fonts only) - ⌘ (command):
U+2318
␣ (space):
U+2423
NewerOlder