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

ftrm-basic

v0.0.0

Published

Footurama Basic Build Blocks

Downloads

3

Readme

Footurama Package: Basic

This package includes basic building blocks for Footurama.

ftrm-basic/inject

Inject values into the realm.

Configuration:

  • input: 0.
  • output: 1. Target pipe for injected values.
  • inject: Function generating values: () => value. Can be deferred using Promises.
  • interval: Interval between two injections in milliseconds.

Example:

// Inject random numbers every second
module.exports = [require('ftrm-basic/inject'), {
	output: 'output-pipe-with-numbers',
	inject: () => Math.random(),
	interval: 1000
}];

ftrm-basic/map

Map values from one pipe to another.

Configuration:

  • input: 1. Values to be mapped
  • output: 1. Mapped values
  • map: Function to map the input to the output: (input) => output. Can be deferred using Promises.

Example:

// Check whether input is greater or equal to zero
module.exports = [require('ftrm-basic/map'), {
	input: 'input-pipe-with-numbers',
	output: 'output-pipe-with-booleans',
	map: (input) => input >= 0
}];

ftrm-basic/to-writable

Write values from a pipe into a writable stream. Useful for debug logging to stdout!

Configuration:

  • input: 1. Values to be written to the stream.
  • output: 0.
  • stream: Instance of stream.Writable.
  • dontCloseStream: Don't close the stream on exit. This is required when writing to process.stdout. This stream cannot be closed.
  • format: Function to format incoming values to chunks for the stream: (value, timestamp, src) => chunk. timestamp is the time when value was created. src is the tubemail event locally raised when the value has been received. srv.event contains the actual event. Useful when working with wild characters in the input pipe.

Example:

// Debug log all pipes to stdout
module.exports = [require('ftrm-basic/to-writable'), {
	input: '#', // Wild character for all pipes
	stream: process.stdout,
	dontCloseStream: true,
	format: (value, ts, src) => `${new Date(ts)}\t${src.event}\t${value.toString()}\n`
}];

ftrm-basic/from-event

Grab values from arbitrary event busses and output them into pipes.

Configuration:

  • input: 0.
  • output: 1..n. Outputs to write values to. The output's name will be used to select the event accordingly.
  • bus: Instance of EventEmitter.

Example:

// Eventbus emitting 'random' and 'time' event
const EventEmitter = require('events');
const myEventBus = new EventEmitter();
setInterval(() => myEventBus.emit('time', new Date()), 1000);
setInterval(() => myEventBus.emit('random', Math.random()), 3000);

module.exports = [require('ftrm-basic/from-event'), {
	output: {
		'time': 'some-pipe-for-time',
		'random': 'some-pipe-for-random-numbers'
	},
	bus: myEventBus
}];

ftrm-basic/select

Select one input pipe out of many to forward it to the output pipe.

Configuration:

  • input: 1..n. Input pipes to select from.
  • output: 1.
  • weight: Can be either a string or a function.
    • Function: (input, index) => score. Is called for every input. input holds the input's instance and has the properties input.value, input.timestamp and input.expired. index is the respective index in the input array. The input that returned the highest score will be picked for the output. If the function returns undefined it won't be taken into account.
    • String:
      • 'prio': Takes the first input that has a value that is not undefined and is not expired.
      • 'max': Takes the input with the highest value that is not expired.
      • 'min': Takes the input with the lowest value that is not expired.

Example:

// Select 'setpoint' from several inputs
module.exports = [require('ftrm-basic/select'), {
	input: [
		// Possible inputs. First has highest priority.
		// 1. Manual override. One recieved value stays valid for one hour.
		{pipe: 'setpoint.override', expire: 60 * 60 * 1000},
		// 2. From schedule. Will be valid for 10 minutes.
		{pipe: 'setpoint.schedule', expire: 10 * 60 * 1000},
		// 3. No pipe attached, but a constant value is given: Default set point.
		{value: 10}
	],
	output: 'setpoint',
	weight: 'prio'
}];