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

knockout-sync

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knockout-sync - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

2

package.json
{
"name": "knockout-sync",
"version": "0.1.8",
"version": "0.1.9",
"description": "A small backend using knockout mapping to sync entities with a RESTful Backend",

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

@@ -185,5 +185,12 @@ define(['./Exception', './EntityModel', 'lodash', 'knockout', 'knockout-mapping'], function(Exception, EntityModel, _, ko, koMapping) {

this.getEntityMeta = function(entityFQN) {
if (!that.meta[entityFQN]) {
throw new Error("There is no EntityMeta stored for FQN: '"+entityFQN+"'");
}
return that.meta[entityFQN];
};
this.hasEntityMeta = function(entityFQN) {
return !!that.meta[entityFQN];
};
/**

@@ -198,4 +205,4 @@ * Calculates the "inner" mapping passed as second parameter of the constructor to the model

_.each(entityMeta.properties, function(property) {
if (property.type && that.meta[property.type]) {
var propertyEntityMeta = that.meta[property.type];
if (property.type && that.hasEntityMeta(property.type)) {
var propertyEntityMeta = that.getEntityMeta(property.type);

@@ -208,4 +215,6 @@ mapping[property.name] = {

var fqn = that.getEntityFQNFromData(propertyEntityMeta, options.data);
if (options.data.$type) {
var relatedEntity = that.find(propertyEntityMeta.fqn, options.data.$ref);
var relatedEntity = that.find(fqn, options.data.$ref);

@@ -228,3 +237,3 @@ if (relatedEntity) {

} else {
return that.findOrHydrate(propertyEntityMeta.fqn, options.data);
return that.findOrHydrate(fqn, options.data);
}

@@ -239,2 +248,11 @@ }

this.getEntityFQNFromData = function(entityMeta, data) {
// always trust __class from backend
if (data.__class) {
return ko.unwrap(data.__class).replace(/\\/g, '.');
} else {
return entityMeta.fqn;
}
};
this.onHydrate = function(listener) {

@@ -241,0 +259,0 @@ that.hydrateListeners.push(listener);

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