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

cher-tools

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cher-tools - npm Package Compare versions

Comparing version 0.5.6 to 0.5.7

2

package.json
{
"name": "cher-tools",
"version": "0.5.6",
"version": "0.5.7",
"description": "Tools and utilities for the Cher platform",

@@ -5,0 +5,0 @@ "main": "index.js",

'use strict';
const es = require( 'event-stream' );
const utils = require( '../utils' );
const log = require( '../log' )();
const es = require('event-stream');
const utils = require('../utils');
const log = require('../log')();
module.exports = ( deps ) => {
const DataModel = deps.models.get( 'DataModel' );
if ( !DataModel ) {
module.exports = (deps) => {
const SocialContent = deps.models.get('SocialContent');
if (!SocialContent) {
log.error(
'Missing a required dependency for persist stream: DataModel'
);
// return a stream even if the DataModel dependency does not exist so that
'Missing a required dependency for persist stream: SocialContent'
);
// return a stream even if the SocialContent dependency does not exist so that
// we don't break the pipeline.

@@ -19,18 +19,18 @@ return es.through();

return es.through( function pipelineSaveStream ( data ) {
return es.through(function pipelineSaveStream (data) {
const self = this;
let parsed = utils.parse( data, true );
let parsed = utils.parse(data, true);
let dup = false;
// We query the database for this particular item. If it's already in the
// database, we ignore it. Otherwise, we store it then emit it as new data
DataModel
.fetchUnique( parsed.source_id )
.then( function onDataModelFetch ( model ) {
SocialContent
.fetchUnique(parsed.source_id)
.then(function onSocialContentFetch (model) {
let toSave;
if ( !model ) {
toSave = new DataModel( parsed );
if (!model) {
toSave = new SocialContent(parsed);
} else {
log.debug(
'Found duplicate entry for %s Overwriting blob.', parsed.source_id
);
`Found duplicate entry for %s Overwriting blob ${parsed.source_id}`
);
dup = true;

@@ -41,19 +41,16 @@ toSave = model;

return toSave.save();
}).then( ( model ) => {
if ( parsed.flagged && !dup ) {
model.moderate( false )
.catch( ( err ) => {
log.error(
'An error occured while moderating flagged item %s',
parsed.social_id
);
log.error( err );
self.emit( 'error', err );
}).then((model) => {
if (parsed.flagged && !dup) {
model.moderate(false)
.catch((err) => {
const message = `An error occured while moderating flagged item ${parsed.source_id}`;
log.error({ err: err });
self.emit('error', err);
});
}
if ( !dup ) {
self.emit( 'data', data );
if (!dup) {
self.emit('data', data);
}
}).catch( ( e ) => {
self.emit( 'error', e );
}).catch((e) => {
self.emit('error', e);
});

@@ -60,0 +57,0 @@ });

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