tools for behavior, delegation, and state in typescript
npm i peekeasy
import { Behavior } from 'peekeasy'
const behavior = new Behavior([
async data => (data.message = `Hello, ${data.message}!`),
async ({ message }) => console.log(message),
])
// Hello, behavior!
behavior({ message: 'behavior' })
import { Delegate } from 'peekeasy'
const set = new Set<(t: string, u: string) => void>(),
delegate = new Delegate(set)
delegate.add(async message => console.log(...message))
// Hello, delegate!
set.forEach(f => f('Hello,', 'delegate!'))
import { Reference } from 'peekeasy'
function* generate() {
while (true) {
yield 'Hello, reference!'
}
}
const reference = new Reference(generate())
// Hello, reference!
console.log(`${reference}`)
import { Vector } from 'peekeasy'
const vector = new Vector([{ text: 'Hello,' }, { text: 'vector!' }])
// Hello, vector!
console.log(...vector.text)
gh repo clone domrally/peekeasy
cd Documents/Github/peekeasy
npm i
npm stop
npm test
npm start
merge a pull request into main
to publish to npm
Set
and WeakSet
interfacesIteration protocols
Proxy
objectsdelegates
and events
https://domrally.github.io/peekeasy
classDiagram
direction LR
PromiseLike <|.. Promise
PromiseLike *-- Delegate
Promise <.. Delegate
PromiseLike <.. AsyncIterator
IteratorResult o-- AsyncIterator
Iterator -- AsyncIterator
AsyncIterator *-- AsyncIterable
Iterable -- AsyncIterable
AsyncIterable *-- Delegate
IteratorResult o-- Iterator
Iterator *-- Iterable
WeakSet -- Set
WeakSet <|.. Delegate
Iterator <-- Reference
Iterable *-- Vector
class IteratorResult {
done boolean
value any
}
class AsyncIterable {
Symbol.asyncIterator() AsyncIterator
}
class Iterable {
Symbol.iterator() Iterator
}
class Iterator {
next() IteratorResult
}
class AsyncIterator {
next() PromiseLike~IteratorResult~
}
class PromiseLike {
then() PromiseLike
}
link PromiseLike "https://microsoft.github.io/PowerBI-JavaScript/interfaces/_node_modules_typedoc_node_modules_typescript_lib_lib_es5_d_.promiselike.html" "PromiseLike"
class Promise {
finally(onfinally () => void) Promise
}
link Promise "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" "Promise"
class WeakSet {
add() WeakSet
delete() WeakSet
has() boolean
}
link WeakSet "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet" "WeakSet"
class Set {
size number
clear() void
forEach() void
}
link Set "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set" "Set"
class Delegate
link Delegate "https://github.com/domrally/peekeasy/blob/main/src/delegate.ts" "delegate.ts"
class Vector
link Vector "https://github.com/domrally/peekeasy/blob/main/src/vector.ts" "vector.ts"
class Reference
link Reference "https://github.com/domrally/peekeasy/blob/main/src/reference.ts" "reference.ts"
Generated using TypeDoc