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

absync

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absync - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

doc/logo.png

5

index.js

@@ -9,2 +9,4 @@ var conductor = require( "./lib/transaction/conductor" );

var ChangeSet = require( "./lib/history/changeset" );
module.exports = {

@@ -16,3 +18,4 @@ conductor : conductor,

TypeHelper : TypeHelper,
TypeInfo : TypeInfo
TypeInfo : TypeInfo,
ChangeSet : ChangeSet
};

0

lib/transaction/conductor.js

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

"use strict";
var _ = require( "lodash" );
var EventEmitter = require( "events" ).EventEmitter;
var extend = require( "mongoose-schema-extend" );

@@ -9,2 +10,3 @@ var mongoose = require( "mongoose" );

var TypeInfo = require( "./info.js" );
var util = require( "util" );

@@ -32,2 +34,4 @@ /**

util.inherits( Type, EventEmitter );
/**

@@ -34,0 +38,0 @@ * Construct a new type.

@@ -19,3 +19,3 @@ "use strict";

* Removes fields from an instance which are set to null.
* @param {Object} instance The instance of the type on which operations should be performed.
* @param {Object|Object[]} instance The instance of the type on which operations should be performed.
* @param {Boolean} [clone=false] Should the operation be performed on a copy of the instance instead?

@@ -52,3 +52,3 @@ * @returns {*} The instance with the null fields removed.

* Removes hidden fields from an instance of the type.
* @param {Object} instance The instance of the type on which operations should be performed.
* @param {Object|Object[]} instance The instance of the type on which operations should be performed.
* @param {String} [userClass="user"] The user class for which to check the hidden attribute.

@@ -100,3 +100,3 @@ * @param {Boolean} [clone=false] Should the operation be performed on a copy of the instance instead?

* Removes read-only fields from an instance of the type.
* @param {Object} instance The instance of the type on which operations should be performed.
* @param {Object|Object[]} instance The instance of the type on which operations should be performed.
* @param {String} [userClass="user"] The user class for which to check the readonly attribute.

@@ -148,3 +148,3 @@ * @param {Boolean} [clone=false] Should the operation be performed on a copy of the instance instead?

* Replaces concealed fields from an instance of the type.
* @param {Object} instance The instance of the type on which operations should be performed.
* @param {Object|Object[]} instance The instance of the type on which operations should be performed.
* @param {String} [userClass="user"] The user class for which to check the concealed attribute.

@@ -196,2 +196,57 @@ * @param {Boolean} [clone=false] Should the operation be performed on a copy of the instance instead?

/**
* Replaces complex type instances with their ID.
* @param {Object|Object[]} instance The instance of the type on which operations should be performed.
* @param {Boolean} [clone=false] Should the operation be performed on a copy of the instance instead?
* @returns {*} The instance with the complex fields replaced.
*/
TypeHelper.prototype.reduceComplex = function( instance, clone ) {
if( null === instance ) {
throw new Error( "Type instance cannot be null!" );
}
var targetInstance = ( clone ) ? _.clone( instance ) : instance;
// Handle arrays.
if( Array.isArray( instance ) ) {
var helper = this;
var results = [];
instance.forEach( function( element ) {
results.push( helper.reduceComplex( element, clone ) );
} );
return results;
}
for( var propertyName in targetInstance ) {
if( !this.typeInfo.isComplex( propertyName ) ) {
reduceObject( targetInstance[ propertyName ] );
}
}
return targetInstance;
function reduceObject( entity, depth ) {
if( 10 < depth ) {
log.error( "Entity nesting too deep! Complex reduction can not be completed." );
return null;
}
for( var propertyName in entity ) {
if( !entity.hasOwnProperty( propertyName ) ) {
continue;
}
if( Array.isArray( entity[ propertyName ] ) ) {
entity[ propertyName ] = reduceObject( entity[ propertyName ], depth + 1 );
continue;
}
if( entity[ propertyName ] && entity[ propertyName ].id ) {
entity[ propertyName ] = entity[ propertyName ].id;
continue;
}
}
return entity[ propertyName ];
}
};
return TypeHelper;

@@ -198,0 +253,0 @@ })();

@@ -0,0 +0,0 @@ "use strict";

{
"name": "absync",
"version": "0.1.1",
"version": "0.2.0",
"description": "absync",

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

@@ -0,1 +1,3 @@

![](doc/logo.png)
absync is a highly opinionated framework to synchronize data pools in MEAN applications.

@@ -2,0 +4,0 @@

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