Add rest of build files and README.md

rasch
Sep 11, 2023, 1:20 AM
IKXCBBCOR65P7OYZELFTKO3VZCSHOFKSGLVYVF6J2KRFZIFSA5OAC

Dependencies

Change contents

  • replacement in bun.lockb at line 1
    [2.88][2.89:1329]()
    [2.88]
  • file addition: README.md (----------)
    [4.1]
    # pubsub
    ultra-minimal pubsub module written in TypeScript
    ## install
    ```sh
    pnpm add @rasch/pubsub
    # or with bun
    bun add @rasch/pubsub
    ```
    ## usage
    ```js
    import { publish, subscribe, unsubscribe } from "@rasch/pubsub"
    import { welcome, tryagain } from "./fakeCallbackFunctions.js"
    subscribe("login", welcome)
    subscribe("loginError", tryagain)
    if (user.isLoggedIn()) {
    publish("login", user.name)
    } else {
    publish("loginError", `Incorrect username "${user.name}" or password!`)
    }
    unsubscribe("*")
    ```
    ## api
    ### subscribe
    ```txt
    subscribe :: string -> (...a -> void) -> void
    ```
    Attach a callback function to an event.
    ```typescript
    subscribe("event", myFunction)
    ```
    ### publish
    ```txt
    publish :: (string, ...a) -> void
    ```
    Run all of the functions attached to an event with the given arguments.
    ```typescript
    publish("event", arg)
    publish("event", arg1, arg2, ...)
    ```
    ### unsubscribe
    ```txt
    unsubscribe :: (string, ((...a -> void) | undefined)) -> void
    ```
    Stop listening for events.
    ```typescript
    // stop listening to a single event callback function
    unsubscribe("event", myFunction)
    // stop listening for all callback functions on event
    unsubscribe("event")
    // cancel all subscriptions
    unsubscribe("*")
    ```
  • edit in .ignore at line 1
    [2.1544]
    [2.1545]
    dist
  • file addition: .build.yml (----------)
    [4.1]
    image: nixos/latest
    packages:
    - bun
    - nodejs_20
    - pijul
    environment:
    project: pubsub
    secrets:
    - 2b8f0d2a-cab9-451d-b684-6b89582fb7b0 # NPM publish token
    tasks:
    - setup: |
    pijul clone https://nest.pijul.com/rasch/"$project"
    cd "$project"
    bun install
    - stop_if_not_release: |
    cd "$project"
    current=$(pijul log --limit 1 --state | grep '^State' | cut -d ' ' -f 2)
    tag=$(pijul tag | grep '^State' | cut -d ' ' -f 2)
    test "$current" = "tag" || complete-build
    - release: |
    cd "$project"
    bun run build
    echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc
    set +x
    . ~/.env
    set -x
    npm publish --access public