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
type AConstructorTypeOf<T> = new (...args:any[]) => T; |
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 { createSignal } from "./strong-signal" | |
// declare the signal | |
const onNumber = createSignal<(num: number) => void>(); | |
// ok | |
onNumber(function(num) {}); | |
// compilation error! second argument not allowed | |
onNumber(function(num, secondArg) {}); |
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
-main Sandbox.hx | |
-js Sandbox.js |
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
interface Serializer<State, API= any> { | |
getState() : State; | |
getAPI() : API; | |
} | |
class MyAPI<State> { | |
state: State; | |
my() {} | |
api() {} | |
methods() {} |
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
// npm install nanoid | |
import * as generateId from "nanoid/generate"; | |
class MyRoomHandler extends Room { | |
onInit () { | |
// this may introduce colliding `roomId`, use at your own risk | |
this.roomId = generateId("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ", 6); | |
} | |
} |
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
export function* generateUserAgent() { | |
let webkitVersion = 10; | |
let chromeVersion = 1000; | |
const so = [ | |
'Windows NT 6.1; WOW64', | |
'Windows NT 6.2; Win64; x64', | |
"Windows NT 5.1; Win64; x64",, | |
'Macintosh; Intel Mac OS X 10_12_6', | |
"X11; Linux x86_64", |
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
///<reference types="mocha" /> | |
import { assert, expect } from "chai"; | |
import { StateContainer, DataChange } from "../src"; | |
function clone (data: any) { | |
return JSON.parse(JSON.stringify(data)); | |
} | |
describe("StateContainer", () => { | |
let container: StateContainer<any>; |
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
var Benchmark = require('benchmark'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var fossilDelta = require('../fossil-delta.js'); | |
// Silence error logging. | |
fossilDelta.logError = function() {} | |
var makeArray = function(buf) { | |
var a = new Array(buf.length); |
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 * as Benchmark from "benchmark"; | |
// Array.prototype.concat() | |
const concat = function(...args: any[]) { | |
let arr = [1,2,3] | |
return arr.concat(args); | |
}; | |
// "concat" manually, performs better | |
const manual = (...args: any[]) => { |
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
// ... | |
registerListeners () { | |
this.room.state.listen("cars/:id", "add", (clientId: string, value: any) => { | |
this.addCar(clientId, value); | |
}); | |
this.room.state.listen("cars/:id", "remove", (clientId: string) => { | |
this.view.removeCar(clientId); | |
}); |