Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@briancavalier/most-behavior
Advanced tools
EXPERIMENTAL Don't use this for anything real ... yet.
Continuous time-varying values for most.js. Behaviors are the continuous complement to most.js discrete Event Streams, or, if you prefer, the "pull" complement to most.js "push" Event Streams.
Feedback welcome via gitter, but seriously, don't use it for anything real yet.
npm i --save @briancavalier/most-behavior
A Behavior is a continuous value. In contrast to an Event Stream which has discrete occurrences at particular instants in time, a Behavior's value is defined at all real number (not integer) values of time and may vary continuously (or not) over time.
Because they are defined for all real number values of time, a Behavior must be sampled to obtain its value at specific instants in time. To sample a Behavior, pass it an Event Stream whose occurrences define all the points in time at which the behavior's value should be sampled.
Here's a simple example. Note that because clock
is "pull", it does no work at the instants between clicks, where it is not being sampled.
import { time } from '@briancavalier/most-behavior'
import { click } from '@most/dom-event'
// A Behavior that always represents milliseconds since the application started
const clock = time
// Sample the clock each time the user clicks
const timeAtEachClick = sample(clock, click(document))
For now, see the examples dir for more realistic code, how to run a @most/core
app that integrates behaviors, etc.
A behavior that represents the current time in milliseconds since the application started.
Create a Behavior whose value is always a
.
Create a Behavior that starts with an initial value and updates to each new value in the Event Stream.
Apply a function to a Behavior at all points in time.
Apply a (time-varying) function to a Behavior at all points in time.
Apply a function to 2 Behaviors at all points in time.
Sample a Behavior's value at every occurrence of an Event Stream.
Sample a Behavior at every occurrence of an event, and compute a new event from the (event, sample) pair.
Potentially useful APIs we could add:
Allow events only when a Behavior's value is true
.
Create a Behavior with an initial value and an Event Stream carrying update functions.
Like scan, but produces a Behavior. Needs a helpful name ...
Generalized scan for Behaviors. When event occurs, sample Behavior, and apply a function that creates a new Behavior. Somewhat like switch
. Needs a helpful name ...
Create a Behavior representing the number of event occurrences.
Create a Behavior that acts like an initial Behavior and switches to act like each new Behavior that occurs in the Event Stream.
FAQs
behave
The npm package @briancavalier/most-behavior receives a total of 3 weekly downloads. As such, @briancavalier/most-behavior popularity was classified as not popular.
We found that @briancavalier/most-behavior demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.