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.
Pronounced "effin' flow" because it's so badass, fnFlow is a Javascript control flow library heavily influenced by Caolan McMahon's async that encourages a proper functional design pattern.
Pronounced "effin' flow" because it's so badass, fnflow is a Javascript control flow library heavily influenced by Caolan McMahon's async that encourages a proper functional design pattern.
For a complicated series of both asynchronous and synchronous tasks, using the Flow class makes adding new tasks much easier and makes the code more readable. It also encourages you to define functions in places where they can be reused more easily. This makes it an excellent choice for design patterns like MVC where it is a goal to strive for "fat model, skinny controller."
Basic Usage
var Flow = require('fnflow').Flow, Task = Flow.Task;
var flow = new Flow({
author: new Task(Author.getByName, 'author_name'),
genre: new Task(Genre.getByName, 'genre_name'),
books: new Task(Book.findByAuthorAndGenre, 'author', 'genre'),
});
flow.execute({ author_name: 'Brandon Sanderson', genre_name: 'Fantasy' }, function(err, results){
if(err) return console.error(err);
console.log(results.books.length + " books found.");
});
...which translates to the following workflow:
Constructor function. It determines the best order for running functions based on their requirements. Flow automatically determines which functions depend on other functions to complete first by examining all function arguments, and each function is run as soon as its requirements are satisfied. If any of the functions pass an error to their callback, that function will not complete (so any other functions depending on it will not run) and the main callback will be called immediately with the error. The main callback receives an object containing the results of functions which have completed so far.
Arguments
Running Multple Sets of Tasks in Parallel
var flow = new Flow({
author: new Task(Author.getByName, 'author_name'),
books: new Task('author.getBooks'),
});
flow.execute([
{ author_name: 'Brandon Sanderson' },
{ author_name: 'Jack Vance' }
], function(err, results) {
if(err) return console.error(err);
results.forEach(function(result){ console.log(result.author_name + " wrote " + result.books.length); });
});
...which translates to the following workflow:
Constructor function. Use this constructor for nesting Flows. Nesting Flows is useful when you want to execute a set of tasks against each item in an Array result of a parent Flow.
Arguments
Nested Flow Example
var flow = new Flow({
author: new Task(Author.getByName, 'author_name'),
books: new Task('author.getBooks'),
books_data: new Flow('books', {
pages: new Task('books.getPages'),
words: new Task('books.getWords')
})
});
flow.execute({ author_name: 'Brandon Sanderson' }, function(err, results) {
if(err) return console.error(err);
var total_pages = 0, total_words = 0;
results.books_data.forEach(function(book_data){
total_pages += book_data.pages;
});
console.log(results.author_name + " wrote " + total_pages + " pages and " + total_words + " words.");
});
...which translates to the following workflow:
Constructor function. Represents an asynchronous function whose final argument is a callback function(err, value).
Explicitly specify the names of tasks that must complete prior to the execution of this task. This is useful when a requisite task does not yield a value that is meaningful to this task.
Example
var flow = new Flow({
user: new Task(User.getByUsername, 'username'),
current_user: new Task(User.getByUsername, 'current_username')
checkAuthorization: new Task(user.checkAuthorization, 'current_user')
updateUser: new Task(user.update, 'user_data').requires('checkAuthorization'),
});
flow.execute({
username: "jsmith",
current_username: "bjoe",
user_data: { email: 'bjoe@shutterstock.com' }
}, function(err, results){
if(err) return console.error(err);
console.log(results.books.length + " books found.");
});
...which translates to the following workflow:
Exit the Flow exeuction with an error if the result of the task does not yield a value.
Example
var flow = new Flow({
author: new Task(Author.getByName, 'author_name').assertExists(),
books: new Task(Book.findByAuthor, 'author'),
});
flow.execute({ author_name: 'Brandon Sanderson' }, function(err, results){
if(err) return console.error(err); //this will be true if there was no author found
console.log(results.books.length + " books found.");
});
...which translates to the following workflow:
This library was developed by David Fenster with major contributions from Ben Kovacevich at Shutterstock
Copyright (C) 2013 by Shutterstock Images, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Pronounced "effin' flow" because it's so badass, fnFlow is a Javascript control flow library heavily influenced by Caolan McMahon's async that encourages a proper functional design pattern.
The npm package fnflow receives a total of 4 weekly downloads. As such, fnflow popularity was classified as not popular.
We found that fnflow 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.
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.