Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

littlefork

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

littlefork - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

19

_dist/hasher.js

@@ -6,3 +6,3 @@ 'use strict';

});
exports.hashUnit = exports.envelopeHasher = exports.contentHasher = exports.idHasher = exports.fieldHasher = exports.baseHasher = undefined;
exports.hashUnit = exports.envelopeHasher = exports.contentHasher = exports.idHasher = exports.fieldHasher = exports.baseHasher = exports.sha256 = exports.sha1 = undefined;

@@ -17,10 +17,11 @@ var _fp = require('lodash/fp');

var hash = function hash(data) {
var text = (0, _fp.isString)(data) ? data : JSON.stringify(data);
var sha1sum = _crypto2.default.createHash('sha1');
sha1sum.update(text);
return sha1sum.digest('hex');
};
var hash = (0, _fp.curry)(function (type, data) {
return _crypto2.default.createHash(type).update((0, _fp.isString)(data) ? data : JSON.stringify(data)).digest('hex');
});
var sha1 = exports.sha1 = hash('sha1');
var sha256 = exports.sha256 = hash('sha256');
// FIXME: This seems to be a bad name choice.
var baseHasher = exports.baseHasher = hash;
var baseHasher = exports.baseHasher = sha1;

@@ -58,2 +59,4 @@ // Return a unit with a new hash value set.

exports.default = {
sha1: sha1,
sha256: sha256,
baseHasher: baseHasher,

@@ -60,0 +63,0 @@ fieldHasher: fieldHasher,

@@ -64,3 +64,3 @@ 'use strict';

var transformations = (0, _fp.merge)(ts, module.plugins || {});
var sources = module.query ? (0, _fp.merge)(qs, _defineProperty({}, pluginName, module.source)) : qs;
var sources = module.source ? (0, _fp.merge)(qs, _defineProperty({}, pluginName, module.source)) : qs;

@@ -67,0 +67,0 @@ return [transformations, sources];

@@ -6,3 +6,3 @@ 'use strict';

});
exports.liftA2 = exports.apply = exports.pure = exports.fmap = exports.id = undefined;
exports.liftManyA2 = exports.liftA2 = exports.apply = exports.pure = exports.fmap = exports.id = undefined;

@@ -15,2 +15,4 @@ var _fp = require('lodash/fp');

var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -112,2 +114,27 @@

/**
* Lift many binary functions over two Applicatives.
*
* ```
* liftManyA2 :: Applicative f => [f (a -> b -> Future c)] -> f (Future a)
* -> f (Future b) -> f (Future c)
* liftManyA2 :: Applicative f => [f (a -> b -> Future c)] -> f a -> f b
* -> f (Future c)
* ```
* @param {Array.<Function>} fs A list of binary functions.
* @param {Promise.<Any>} a A promise that resolves to a value.
* @param {Promise.<Any>} b A promise that resolves to a value.
* @returns {Promise.<Any>} The value that that returns when reducing `a` and
* `b` over `fs`.
* @example
* const a = Promise.resolve(envelope);
* const b = Promise.resolve(env);
* liftManyA2([f1, f2], a, b); // f1(a,b).then(r => f2(r, b)).then(...)
*/
var liftManyA2 = exports.liftManyA2 = (0, _fp.curry)(function (fs, a, b) {
return (0, _utils.reduceP)(function (memo, f) {
return liftA2(f, memo, b);
}, a, fs);
});
exports.default = {

@@ -118,3 +145,4 @@ id: id,

apply: apply,
liftA2: liftA2
liftA2: liftA2,
liftManyA2: liftManyA2
};

@@ -20,2 +20,4 @@ 'use strict';

var _shortid = require('shortid');
var _plugin = require('./plugin');

@@ -33,7 +35,2 @@

// To make liftA2 more composeable later on, flip the arguments.
var runPlugin = (0, _fp.curry)(function (plugin, env, envelope) {
return (0, _plugin.liftA2)(plugin, envelope, env);
});
// The following functions provide funtionalities outside of a plugin.

@@ -55,2 +52,10 @@ var stats = (0, _fp.curry)(function (name, envelope) {

var marker = (0, _fp.curry)(function (label, envelope) {
return (0, _fp.merge)(envelope, { data: (0, _fp.map)(function (u) {
return (0, _fp.flow)([(0, _fp.getOr)([], '_lf_markers'), (0, _fp.concat)([label]), _fp.uniq, function (ms) {
return (0, _fp.merge)(u, { _lf_markers: ms });
}])(u);
}, envelope.data) });
});
/**

@@ -100,2 +105,3 @@ * Create a runable littlefork object.

var stream = _baconjs2.default.Bus();
var label = (0, _shortid.generate)();

@@ -127,3 +133,3 @@ var pipeline = (0, _fp.flow)([(0, _fp.map)(function (p) {

return (0, _utils.flowP)([start(stream, name), runPlugin(plugin, { log: log, cfg: cfg }), stats(name), end(stream, name)])(envelope);
return (0, _plugin.liftManyA2)([start(stream, name), (0, _plugin.liftA2)(plugin), marker(label), stats(name), end(stream, name)], envelope, { log: log, cfg: cfg });
}, { queries: queries, data: [], stats: { launchTime: (0, _utils.now)(), p: {} } }, pipeline);

@@ -130,0 +136,0 @@ }).catch(function (e) {

@@ -6,3 +6,3 @@ 'use strict';

});
exports.promisify = exports.reduceP = exports.mapP = exports.flowP = exports.composeP = exports.call = exports.printf = exports.tap = exports.now = exports.defaultFields = exports.assertEnv = exports.retry = exports.contentHashes = exports.idHashes = undefined;
exports.promisify = exports.reduceP = exports.mapP = exports.flowP = exports.composeP = exports.call = exports.printf = exports.tap = exports.now = exports.defaultFields = exports.assertEnv = exports.assertQuery = exports.assertCfg = exports.queriesByType = exports.retry = exports.contentHashes = exports.idHashes = undefined;

@@ -56,2 +56,30 @@ var _fp = require('lodash/fp');

var queriesByType = exports.queriesByType = (0, _fp.curry)(function (type, envelope) {
return (0, _fp.flow)([(0, _fp.filter)(['type', type]), (0, _fp.map)('term')])(envelope.queries);
});
var assertCfg = exports.assertCfg = (0, _fp.curry)(function (expected, envelope, _ref) {
var cfg = _ref.cfg;
var errors = (0, _fp.reduce)(function (memo, e) {
if (!(0, _fp.get)(e, cfg)) {
return (0, _fp.concat)(memo, [e]);
}
return memo;
}, [], expected);
if (!(0, _fp.isEmpty)(errors)) {
throw new Error('Missing configuration options: ' + errors.join(', '));
}
return envelope;
});
var assertQuery = exports.assertQuery = (0, _fp.curry)(function (type, envelope) {
if ((0, _fp.isEmpty)(queriesByType(type, envelope))) {
throw new Error('Query type ' + type + ' not found.');
}
return envelope;
});
// FIXME: Deprecated. Remove as soon as plugins support assertQuery.
var assertEnv = exports.assertEnv = function assertEnv(expected) {

@@ -119,9 +147,7 @@ var existing = (0, _fp.flow)([(0, _fp.pick)(expected), _fp.keys])(process.env);

var flowP = exports.flowP = function flowP(fs) {
return function (x) {
return (0, _fp.reduce)(function (memo, f) {
return memo.then(f);
}, _bluebird2.default.resolve(x), fs);
};
};
var flowP = exports.flowP = (0, _fp.curry)(function (fs, x) {
return (0, _fp.reduce)(function (memo, f) {
return memo.then(f);
}, _bluebird2.default.resolve(x), fs);
});

@@ -132,2 +158,17 @@ var mapP = exports.mapP = (0, _fp.curry)(function (f, xs) {

/**
* Reduce a list of values over an applicative.
*
* ```
* reduceP :: Applicative f => (Future b -> a -> Future b) -> f (Future b)
* -> [a] -> f (Future b)
* reduceP :: Applicative f => (b -> a -> f b) -> b -> [a] -> f b
* ```
* @param {Function.<Promise, any>} f The reduce function, takes a promise as
* accumulator and a value.
* @param {Promise} acc The initial accumulator value.
* @param {Array.<any>} xs A list of values to reduce.
* @example
* reduceP((memo, a) => memo.then(r => r + a), 0, [1,2,3]);
*/
var reduceP = exports.reduceP = (0, _fp.curry)(function (f, acc, xs) {

@@ -145,4 +186,7 @@ return _bluebird2.default.reduce(xs, f, acc);

retry: retry,
assertCfg: assertCfg,
assertQuery: assertQuery,
assertEnv: assertEnv,
defaultFields: defaultFields,
queriesByType: queriesByType,
now: now,

@@ -149,0 +193,0 @@ tap: tap,

{
"name": "littlefork",
"version": "0.5.0",
"version": "0.5.1",
"description": "A sequential data processing pipeline.",

@@ -65,6 +65,6 @@ "main": "_dist/index.js",

"bluebird": "^3.4.7",
"debug": "^2.6.0",
"lodash": "^4.17.4",
"moment": "^2.17.1"
"moment": "^2.17.1",
"shortid": "^2.2.6"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc