Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Action dispatcher for unidirectional data flows. Provides action composition and checks for circular dependencies with a small interface of only 3 functions.
$ npm install barracks
const barracks = require('barracks')
const dispatcher = barracks()
const store = []
dispatcher.on('error', err => console.log(err))
dispatcher.on('insert', data => store.push(data.name))
dispatcher.on('upsert', (data, wait) => {
const index = store.indexOf(data.newName)
if (index !== -1) return wait('insert')
store[index] = data.newName
})
dispatcher('insert', {name: 'Loki'})
dispatcher('upsert', {name: 'Loki', newName: 'Tobi'})
Initialize a new barracks
instance.
Register a new action. Checks for circular dependencies when dispatching. The
callback receives the passed in data and a wait(actions[, cb])
function that
can be used to call other actions internally. wait()
accepts a single action
or an array of actions and an optional callback as the final argument. Only
one callback can be added per action.
Call an action and execute the corresponding callback. Alias:
dispatcher.emit(action[, data])
. Supports strings and
flux-standard-actions
(example).
Handle errors. Warns if circular dependencies exists.
An action dispatcher gets data from one place to another without tightly
coupling the code. The best known use case for this is in the flux
pattern.
Say you want to update a piece of data (for example a user's name), instead of
directly calling the update logic inside the view the action calls a function
that updates the user's name for you. Now all the views that need to update a
user's name can call the same action and pass in the relevant data. This
pattern tends to make views more robust and easier to maintain.
Passing messages around should not be complicated. Many flux
implementations
casually throw around framework specific terminology making new users feel
silly for not following along. I don't like that. barracks
is a package that
takes node's familiar EventEmitter
interface and adapts it for use as an
action dispatcher.
That's fine, but it also means this readme needs to be improved. Would you mind
opening an issue and explain
what you're having difficulty with? I want barracks
to be comprehensive for
developers of any skill level, so don't hesitate to ask questions if you're
unsure about something.
Yes you can
use flux standard actions
with barracks
. Just pass in an FSA compliant object into barracks, and it
will be parsed correctly.
An action dispatcher doesn't need a lot of features to pass a message from A to
B. barracks
was built for flexibility. If you feel you're repeating yourself
a lot with barracks
or are missing a feature, feel free to wrap and extend it
however you like.
In flux it's common to store your application state in a data store. I think a data store should be immutable, single-instance and allow data access through cursors / lenses. At the moment of writing I haven't found a data store I'm pleased with, so I'll probably end up writing one in the near future.
FAQs
Action dispatcher for unidirectional data flows
The npm package barracks receives a total of 20 weekly downloads. As such, barracks popularity was classified as not popular.
We found that barracks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.