New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

glom

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glom

Modanic chain utilizing an accumulating mixin input parameter.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

glom

Tranformation chain utilizing an accumulating mixin (called a glom) input parameter.

Install

npm install glom

Example

If one was to describe the atomic actions required to create a new account using a chain of asynchronous functions, your Glom would look like this:

// A chain of business rules for account creation
new Glom([
  validateUserInput,
  isEmailUnique,
  createUser,
  [createDefaultPermissions, deleteUser, createError, returnJson]  // Sidechain in case of failure
  notifyAdmin,
  registerNewUserStats,
  returnJson
]).run({
  email: 'bob@bob.com',
  password: 'woooo'
}, console.log, console.error);

Additional Usage

var Glom = require('glom');

function incrementData (value, next, error) {
    done({
        value: value + 1
    });

}

function setDataSnapshot (value, next, error) {
    this.snapshots.set('value', value);
    done();
}

function doubleData (value, next, error) {
    if (value > 5) {
        error('Data is too big.');
    } else {
        done({
            value: value * 2
        });
    }
}

function printData (value, next, error) {
    console.log(value);
    done();
}

function revertToSnapshot (messages, next, error) {
    done({
        value: this.snapshots.get('value')
    });
}

Glom([
    incrementData,
    getDataSnapshot,
    [doubleData, revertToSnapshot],
    printData
]).run({
    value: 3
}, function glomDone (glom) {
    console.log('Glom complete with final transformation:');
    console.dir(glom);
}, console.error);

Notice that each method in a Glom has its own parameters, allowing any simple, testable, and potentially isomorphic method to be used by Glom, provided the last two parameters are callbacks named next and error. Please see the tests for more use cases.

FAQs

Package last updated on 04 Jul 2017

Did you know?

Socket

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.

Install

Related posts