- Why?
- Use existing code and libraries, especially for encryption or hashing
- Sharing code for algorithms or compute intensive operations
- Don’t intend expose much (anything?) to the wasm instance
- There some gotchas like 64bit integers
- Browser only, no toolchain
- I have toolchain fatigue and it turns out the latest browsers are kinda great
- import and export, async and await, wasm, etc all work
- I like to use a tiny file server to serve a directory on a port on localhost
- serve
This file contains hidden or 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
/** @template T */ | |
class State { | |
/** @typedef {function(T):void} Callback */ | |
/** | |
* @param {T} initialValue | |
*/ | |
constructor (initialValue) { | |
this.value = initialValue |
This file contains hidden or 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 { createStorage } from './bassics/storage' | |
import { html, until, render } from './bassics/html' | |
const storage = createStorage() | |
const likes = storage.state('likes', fetchLikes()) | |
function reloadLikes () { | |
return likes.update(fetchLikes()) | |
} |
This file contains hidden or 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
/** | |
* @template T | |
* @param {AsyncGenerator<T, void, void>} gen | |
* @returns {AsyncGenerator<[T, number], void, void>} | |
*/ | |
export async function * genIndexes (gen) { | |
let i = 0 | |
for await (const item of gen) { | |
yield [item, i] | |
i++ |
This file contains hidden or 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 Foundation | |
class Timer { | |
private let source: DispatchSourceTimer | |
private let block: () -> () | |
public let isRepeating: Bool | |
init(_ interval: DispatchTimeInterval, repeat shouldRepeat: Bool = false, block: @escaping () -> ()) { | |
self.source = DispatchSource.makeTimerSource() |
This file contains hidden or 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 Cocoa | |
import Combine | |
class Timer: Cancellable, Publisher { | |
enum Error: Swift.Error { | |
case cancelled | |
} | |
typealias Output = Never | |
typealias Failure = Error |
This file contains hidden or 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
Check it out |
This file contains hidden or 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
{{- $original := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) -}} | |
{{- if findRE ".*@2x*." $original.Name -}} | |
{{- .Scratch.Set "image" ($original.Fit "2400x2400 q40") -}} | |
{{- else if findRE ".*@3x*." $original.Name -}} | |
{{- .Scratch.Set "image" ($original.Fit "3600x3600 q40") -}} | |
{{- else -}} | |
{{- .Scratch.Set "image" ($original.Fit "1200x1200 q55") -}} | |
{{- end -}} |
This file contains hidden or 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
name: now | |
on: | |
push: | |
jobs: | |
deploy-prod: | |
name: Deploy prod | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
steps: |
This file contains hidden or 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
🎉 |