peekeasy

Peekeasy

tools for behavior, delegation, and state in typescript

Contents

Use

install

npm i peekeasy

examples

behavior

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' })

delegate

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!'))

reference

import { Reference } from 'peekeasy'

function* generate() {
while (true) {
yield 'Hello, reference!'
}
}

const reference = new Reference(generate())

// Hello, reference!
console.log(`${reference}`)

vector

import { Vector } from 'peekeasy'

const vector = new Vector([{ text: 'Hello,' }, { text: 'vector!' }])

// Hello, vector!
console.log(...vector.text)

Contribute

clone repo

gh repo clone domrally/peekeasy

open directory

cd Documents/Github/peekeasy

download dependencies

npm i

fix and format

npm stop

run tests

npm test

build docs

npm start

deploy

merge a pull request into main to publish to npm

Project

goals

non-goals

  • event system
  • app framework
  • observer pattern
  • finite state machine
  • integration with array programming languages

documentation

https://domrally.github.io/peekeasy

dependencies

internal

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"

external

structure

Generated using TypeDoc