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 context = new AudioContext(); |
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
class Val { | |
final List<dynamic> value; | |
final String token; | |
Val({this.value, this.token}); | |
} | |
void main() { | |
String showVal(Val value) { |
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
if ('paintWorklet' in CSS) { | |
// Safari TP fix. | |
// Safari only accepts source code as a string instead file path. | |
if (navigator.userAgent.includes('Safari') | |
&& !navigator.userAgent.includes('Chrome')) { | |
(async function() { | |
const response = await fetch('paint.js'); | |
const blob = await response.blob(); | |
const reader = new FileReader(); |
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 reader = new FileReader(); | |
reader.addEventListener('load', () => { | |
CSS.paintWorklet.addModule(reader.result); | |
}); | |
reader.readAsText(blob); |
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
(async function() { | |
const response = await fetch('paint.js'); | |
const blob = await response.blob(); | |
})(); |
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
if ('paintWorklet' in CSS) { | |
CSS.paintWorklet.addModule('paint.js'); | |
} |
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
if ('paintWorklet' in CSS) { | |
if (navigator.userAgent.includes('Safari') | |
&& !navigator.userAgent.includes('Chrome')) { | |
// Safari TP fix will be here. | |
} else { | |
CSS.paintWorklet.addModule('paint.js'); | |
} | |
} |
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
<script id="code" type="text/worklet"> | |
class MyPaint { | |
paint(ctx, geom) { | |
ctx.fillStyle = "red"; | |
ctx.fillRect(0, 0, geom.width, geom.height); | |
} | |
} | |
registerPaint('my-paint', MyPaint); | |
</script> |
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
levenshtein(a: string, b: string): number { | |
if (a.length == 0) { | |
return b.length; | |
} | |
if (b.length == 0) { | |
return a.length; | |
} | |
const matrix = []; |
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
sortByDistances(typoPath: string, dictionary: string[]) { | |
const pathsDistance = {} as { [name: string]: number }; | |
dictionary.sort((a, b) => { | |
if (!(a in pathsDistance)) { | |
pathsDistance[a] = this.levenshtein(a, typoPath); | |
} | |
if (!(b in pathsDistance)) { | |
pathsDistance[b] = this.levenshtein(b, typoPath); | |
} |