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
// indexedDB doc: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB#basic_pattern | |
const pdb = new Promise((resolve, reject) => { | |
const request = indexedDB.open("compiledCache", 1); | |
request.onerror = (event) => reject(event); | |
request.onsuccess = (event) => resolve(event.target.result); | |
request.onupgradeneeded = (event) => { | |
request.onsuccess = null; |
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 { Duplex } from 'stream' | |
export default class Duplexify extends Duplex { | |
constructor(writable, readable) { | |
super({ | |
readableObjectMode: readable.readableObjectMode, | |
writableObjectMode: writable.writableObjectMode, | |
readableHighWaterMark: readable.readableHighWaterMark, |
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
// javascript jpeg decoder: https://github.com/eugeneware/jpeg-js/blob/79c4c7ea876d2e7b46981a563fcc4ae8f9e19849/lib/decoder.js | |
// Determine the JPEG compression quality from the quantization tables: https://github.com/ImageMagick/ImageMagick/blob/59f28acff016f6ae5e8b7e6300bcdf97e94affc9/coders/jpeg.c#L879 | |
// JPEG File Layout and Format: http://vip.sugovica.hu/Sardi/kepnezo/JPEG%20File%20Layout%20and%20Format.htm | |
// jpeg constants: https://github.com/LuaDist/libjpeg/blob/6c0fcb8ddee365e7abc4d332662b06900612e923/jpeglib.h#L45 | |
function getQuantizationTables(data) { | |
var quantizationTables = [] | |
var dctZigZag = new Int32Array([ |