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 { resolve, extname } from "path"; | |
import { readdir, readFile, writeFile } from "fs/promises"; | |
async function* getFiles(dir, exclude) { | |
const dirents = await readdir(dir, { withFileTypes: true }); | |
for (const dirent of dirents) { | |
const res = resolve(dir, dirent.name); | |
if (exclude.test(res)) continue; | |
if (dirent.isDirectory()) { | |
yield* getFiles(res, exclude); |
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 { | |
changed, | |
createComponent, | |
createApp, | |
createQuery, | |
createType, | |
Group, | |
Format, | |
createSchema, | |
useConst, |
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
export default ''; | |
type Tail<T extends any[]> = T extends [any, ...infer U] ? U : never; | |
type Dispatch = (state: any, ...args: any[]) => any; | |
type DispatchState<D extends Dispatch> = Parameters<D>[0] | ReturnType<D>; | |
type DispatchApi = { [key: string]: Dispatch }; | |
type State<D extends DispatchApi> = { | |
[K in keyof D]: DispatchState<D[K]>; | |
}[keyof D]; |
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 { | |
after, | |
App, | |
Component, | |
Resource, | |
useKeyboard, | |
useQuery, | |
useResource, | |
World, | |
} from "@javelin/ecs" |
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 { | |
createComponentType, | |
number, | |
query, | |
Query, | |
Selector, | |
SelectorResult, | |
World, | |
} from "@javelin/ecs" | |
import React, { |
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 { produce } from "immer"; | |
type Reducer<S, A> = (state: S, action: A) => S; | |
interface ISelectorMap<S> { | |
[key: string]: (state: S, ...args: any[]) => any; | |
} | |
interface IActionCreatorMap { | |
[actionType: string]: (...args: any) => any; |
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 React, { Component, Fragment } from "react"; | |
import { render } from "react-dom"; | |
// Constrain | |
// A component that takes a render prop (children) and passes a proxied | |
// version of remaining props to the render prop function. When a prop is | |
// accessed in the render prop function, Constrain will re-render when | |
// that prop changes in the future. | |
class Constrain extends Component { |
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
type Ctor<T> = new (...args: any[]) => T | |
abstract class BaseComponent { | |
abstract update(): IterableIterator<any> | |
protected children: BaseComponent[] = [] | |
protected getComponent(ctor: Ctor<BaseComponent>) { | |
return this.children.find(x => x instanceof ctor) | |
} |
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 $rest = Symbol('rest'); | |
const $normal = Symbol('normal'); | |
const $optional = Symbol('optional'); | |
const $pattern = Symbol('pattern'); | |
const eq = a => b => a === b; | |
const toString = val => Object.prototype.toString.call(val).split(' ')[1].slice(0, -1); | |
const isString = a => typeof a === 'string'; | |
const isArray = a => Array.isArray(a); |
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 _ensureNew = (ctor) => { | |
const fn = (...args) => !(this instanceof ctor) ? new ctor(...args) : ctor(...args); | |
fn.prototype = ctor.prototype; | |
return fn; | |
} | |
const ensureNew = (ctor) => { | |
const fn = _ensureNew(ctor); | |
fn.extend = Backbone.Model.extend; | |
return fn; |
NewerOlder