New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

llama

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

llama

Wooley, sure-footed. A very small kit of reusable UI utilities.

latest
Source
npmnpm
Version
2.2.0
Version published
Maintainers
1
Created
Source

Llama toolkit

Wooly, sure-footed, a thin layer above vanilla JS for SPA dev (no dependencies).

Provides:

  • a Component API
  • an event-bus
  • a router

API Doc

Table of Contents

llama

Set all the Llama goodness together

Parameters

  • options Object the configuration options

    • options.box string? the id of the div we load components in
    • options.eventBus EventBus? an event-bus to pass to the different Components
    • options.context Object? a shared context object for all the routes
    • options.routes Object<string, (Class<Component> | RouteTarget)> the description of routes
    • options.logger Console? define a logger, can be {logger: console} to send on the javascript console

RouteTarget

Type: Object

Properties

  • type Class<Component>?
  • name string? name of the component to serve as source for event listeners
  • box string? the id of an HTML element the component is rendered into
  • sub_box string? the id of an HTML element the embedded sub-component are rendered into
  • css string? a string of CSS to be injected
  • logger Console? define a logger, can be {logger: console} to send on the javascript console
  • embed Object<string, RouteTarget> embedded route

Component

Common ground for vanilla Widget Component

Parameters

  • options Object a set of option al

    • options.name string? name of the component to serve as source for event listeners
    • options.box string? the id of the HTMLElement to which we want to plug the component
    • options.eventBus EventBus? to receive and send events
    • options.context Object<string, any>?
    • options.logger Console? define a logger, can be {logger: console} to send on the javascript console
    • options.css string?

listen

Listen events

call

Call for loading of the component

Parameters

load

Load component inside the box

Parameters

unload

Unload component

prepareBox

Returns (ShadowRoot | HTMLElement)

populate

Parameters

addChildren

Parameters

removeChildren

Parameters

init

init the component after appending to DOM

Parameters

postLoad

activate after load

Parameters

clean

clean the component after removing from DOM

on

Attach an event listener for this source component

Parameters

emit

Emit an event for a given key that are sent to every attached events listeners

Parameters

  • k string the event key
  • p ...any the optional args

gId

Parameters

Returns HTMLElement

addEvtById

Parameters

hasHTML

Returns boolean

empty

Clear the box contents

Parameters

  • box Node (optional, default this.prepareBox())

fragmentFromHtml

Generate DOM Element from source HTML

Parameters

Returns DocumentFragment the generated DOM Element

injectCSS

Inject component defined CSS into the box (if it exists)

Parameters

  • box Node (optional, default this.prepareBox())

injectHTML

Inject component defined HTML into the box (if it exists)

Parameters

HostComponent

A component that host embedded Component

setSubRoute

Parameters

SimpleEventBus

A simple event bus to enable event-driven architecture

Parameters

  • options Object optional parameters

    • options.name string? define a name, in a multi EventBus scenario
    • options.logger Console? define a logger, can be {logger: console} to send on the javascript console

on

Attach an event listener for a source

Parameters

  • s string name of the source of the listener
  • e (string | Array<string>) the event(s) key(s) to attach the listener
  • f

emit

Emit an event for a given key that are sent to every attached events listeners

Parameters

  • k string the event key
  • p ...any the optional args

clear

Clear event listeners for a source

Parameters

  • s string the name of the source to clear events for
  • filter (optional, default ()=>true)

SequenceEventBus

A Complex event bus to enable event-driven architecture with a before and after event hook

Parameters

  • options Object optional parameters

    • options.logger Console? define a logger, can be {logger: console} to send on the javascript console

on

Attach an event listener for a source

Parameters

  • s string name of the source of the listener
  • e (string | Array<string>) the event(s) key(s) to attach the listener
  • f

emit

Emit an event for a given key that are sent to every attached events listeners

Parameters

  • k string the event key
  • p ...any the optional args

clear

Clear event listeners for a source

Parameters

  • s string the name of the source to clear events for
  • filter (optional, default ()=>true)

Router

A simple router for Llama Component

Parameters

  • eventBus EventBus

  • options object?

    • options.logger Console? define a logger, can be {logger: console} to send on the javascript console

routes

Properties

before

Parameters

on

Parameters

run

Run the router

stop

Stop the router

go

Go to a route matching the given path

Parameters

route

Route the browser

FAQs

Package last updated on 02 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts