npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tf-util

v1.0.2

Published

General non-mud specific utility functions for TinyFugue

Downloads

14

Readme

tf-util

General utility modules and functions for TinyFugue

This library provides supplemental functionality that I would have liked to see included in the built-in libraries.

Modules

main.tf

Main entry point. This provides /requires for all modules in this library.

containers.tf

Support for stacks, queues, and dequeues.

It's actually all just dequeues with stack and queue convenience functions mapped to their dequeue implementations.

Dequeue functions

  • dequeue_init(queueName)

    Create a user variable for a dequeue container. Clobbers any existing data in that variable.

  • dequeue_length(queueName)

    Return the number of elements in a container.

  • dequeue_append(queueName, value)

    Add an element to the end of the dequeue.

  • (TODO) dequeue_prepend(queueName, value)

    Add an element to the beginning of the dequeue.

  • dequeue_popFirst(queueName)

    Remove the first element in the dequeue and return it.

  • dequeue_popLast(queueName)

    Remove the last element in the dequeue and return it.

Aliases

  • stack_init(...)

    Alias for dequeue_init(...)

  • stack_length(...)

    Alias for dequeue_length(...)

  • stack_push(...)

    Alias for dequeue_append(...)

  • stack_pop(...)

    Alias for dequeue_popLast(...)

  • queue_init(...)

    Alias for dequeue_init(...)

  • queue_length(...)

    Alias for dequeue_length(...)

  • queue_push(...)

    Alias for dequeue_append(...)

  • queue_pop(...)

    Alias for dequeue_popFirst(...)

events.tf

Basic event firing and observing mechanism.

This is great for decoupling bits of code. Events should be named with just letters and periods. The order in which event listeners are called is undefined.

  • event_addListener(eventName, callbackMacroName)

    Add a listener function to be called when the event is fired.

  • event_removeListener(eventName, callbackMacroName)

    Remove a listener function from the list of callbacks for a given event.

  • `event_fire(eventName, parametersForCallback, ...)

    Fire an event and pass the given parameters to each registered callback.

list-macros.tf

loader.tf

logging.tf

  • list_macros(regex)

    Return a space-delimited list of macros matching the given regular expression.

redis.tf

  • redis<Command>(parameters)

    Send the given command to the Redis server. Many basic commands are supported. See source for exhaustive list.

unit-test.tf

  • tfunit_declareGroup(groupName)

    Declare of a group of unit tests that will be run together.

  • tfunit_endGroup()

    Ends the current group of unit tests and runs them.

  • tfunit_assertTrue(value, message)

  • tfunit_assertEqual(expected, observed, message)

  • tfunit_assertStrEqual(expected, observed, message)

    Basic assert messages. StrEqual uses the =~ operator while Equal uses ==.

  • tfunit_testGroup(groupName)

    Run the unit tests in the named test group.

variables.tf

It may seem redundant, but providing a more robust system for managing variables can be a great way to provide flexibility in handling variable persistence and events.

  • declareVar(varName, default)

    Declare a variable and make it available possibly with a default value. This is non-destructive if the variable already exists.

  • setVar(varName, newValue)

    Change the value of a given variable

  • getVar(varName)

    Get the current effective value of the variable.

  • saveVars(filename)

  • loadVars(filename)

    Save/Load all user-land variables to a file in TF_NPM_ROOT/data/variables.

  • watchVar(varName, callback)

  • unwatchVar(varName, callback)

    Watch or unwatch for changes in a variable. The callback should be of the signature `callback(oldVal, newVal). The callback cannot prevent the change from occurring.