Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
fairmont-reactive
Advanced tools
Functional reactive programming in JavaScript and CoffeeScript.
Fairmont/Reactive is a JavaScript library for functional reactive programming.
start(flow([
events("request", server),
select(spread(function(request) {
return request.method === "GET";
})),
select(spread(function(request) {
return request.url === "/";
})),
tee(spread(function(ignored, response) {
response.statusCode = 200;
response.write("hello, world");
response.end();
})),
map(spread(logger));
]));
start flow [
events "request", server
select spread (request) -> request.method == "GET"
select spread (request) -> request.url == "/"
tee spread (ignored, response) ->
response.statusCode = 200
response.write "hello, world"
response.end()
map spread logger
]
You can get a feel for what Fairmont can do for you by checking out the examples.
An iterator is an ES6 iterator, with a next
function that produces a value wrapper.
A value wrapper is what iterators produce, with done
and value
properties.
These are part of the ES6 standard.
An iterator function is a function that returns a value wrapper. This is an abstraction introduced by Fairmont/Reactive that allows us to leverage a functional programming style when using iterators. Since iterator functions are isomorphic to iterators, we'll call them iterators for convenience when it isn't ambiguous.
An asynchronous iterator is an iterator that produces promises that resolve to value wrappers. These are a proposed part of ES7. An asynchronous iterator function is a function that returns promises that resolve to value wrappers.
A reactor is Fairmont lingo for an asynchronous iterator. Simiarly, a reactor function is Fairmont-speak for an asynchronous iterator function. Since reactor functions are isomorphic to reactors, we'll call them reactors for convenience when it isn't ambiguous.
When talking about values that could be iterators or reactors, we will sometimes say producers.
An adapter creates a producer (an iterator or reactor) from a non-producer. An iterator filter is a function that takes an iterator and returns another iterator. Iterator filters are just called filters for convenience whenever it isn't ambiguous.
An iterator reducer is a function that takes an iterator and returns a value that isn't an iterator. Iterator reducers are just called reducers for convenience whenever it isn't ambiguous.
When talking about functions that could be adapters, filters, or reducers, we will sometimes say transforms.
Most transforms are implemented for both iterators and reactors.
For example, if we pass an iterator to map
we'll get back an iterator. Whereas if we pass it a reactor, we'll get back a reactor.
Similarly, if we pass an iterator to collect
we'll get back an array.
If we pass it a reactor, we'll get back a promise that resolves to an array.
Many values that aren't iterators or reactors will be coerced into one or the other when passed to a transform or reduction.
For example, if you pass an array into map
, the array will be coerced into an iterator.
Similarly, if you pass a promise into map
, the promise will be coerced into a reactor.
Fairmont takes full advantage of ES6+ features like iterators (including async iterators, called reactors), generators, and promises. Inspired by libraries like Underscore and many others, Fairmont features include:
Fairmont is still under heavy development and is beta
quality, meaning you should probably not use it in your production code.
You can get an idea of what we're planning by looking at the issues list. If you want something that isn't there, and you think it would be a good addition, please open a ticket.
FAQs
Functional reactive programming in JavaScript and CoffeeScript.
The npm package fairmont-reactive receives a total of 1,246 weekly downloads. As such, fairmont-reactive popularity was classified as popular.
We found that fairmont-reactive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.