can-define-backup
Advanced tools
Comparing version 1.0.0 to 2.0.0-pre.2
//allows you to backup and restore a map instance | ||
var compare = require('can-set/src/compare'); | ||
var assign = require('can-assign'); | ||
var canReflect = require('can-reflect'); | ||
var SimpleObservable = require('can-simple-observable'); | ||
var diffDeep = require("can-diff/deep/deep"); | ||
var diffMap = require("can-diff/map/map"); | ||
@@ -46,7 +47,20 @@ var flatProps = function (a, cur) { | ||
var currentValue = this.serialize(); | ||
var aParent, bParent, parentProp; | ||
var compares = {}; | ||
var options = { deep: !! checkAssociations }; | ||
return !compare.equal(currentValue, backupStore, aParent, bParent, parentProp, compares, options); | ||
var patches; | ||
if(!! checkAssociations) { | ||
patches = diffDeep(currentValue, backupStore); | ||
} else { | ||
patches = diffMap(currentValue, backupStore).filter(function(patch){ | ||
// only keep those that are not a set of deep object | ||
if(patch.type !== "set") { | ||
return true; | ||
} else { | ||
// check values .. if both objects ... we are not dirty ... | ||
var curVal = currentValue[patch.key], | ||
backupVal = backupStore[patch.key]; | ||
var twoObjectsCompared = curVal && backupVal && typeof curVal === "object" && typeof backupVal === "object"; | ||
return !twoObjectsCompared; | ||
} | ||
}); | ||
} | ||
return patches.length; | ||
}, | ||
@@ -53,0 +67,0 @@ |
{ | ||
"name": "can-define-backup", | ||
"version": "1.0.0", | ||
"version": "2.0.0-pre.2", | ||
"description": "Backup and restore a DefineMap state", | ||
@@ -12,5 +12,4 @@ "homepage": "https://canjs.com", | ||
"scripts": { | ||
"preversion": "npm test && npm run build", | ||
"version": "git commit -am \"Update dist for release\" && git checkout -b release && git add -f dist/", | ||
"postversion": "git push --tags && git checkout - && git branch -D release && git push", | ||
"preversion": "npm test", | ||
"postpublish": "git push --tags && git push", | ||
"testee": "testee test.html --browsers firefox", | ||
@@ -27,24 +26,11 @@ "test": "npm run jshint && npm run testee", | ||
}, | ||
"main": "dist/cjs/can-define-backup", | ||
"browser": { | ||
"transform": [ | ||
"cssify" | ||
] | ||
}, | ||
"browserify": { | ||
"transform": [ | ||
"cssify" | ||
] | ||
}, | ||
"main": "can-define-backup", | ||
"keywords": [ | ||
"canjs" | ||
], | ||
"steal": { | ||
"main": "can-define-backup" | ||
}, | ||
"dependencies": { | ||
"can-assign": "^1.1.1", | ||
"can-define": "^2.0.0", | ||
"can-diff": "<2.0.0", | ||
"can-reflect": "^1.11.0", | ||
"can-set": "^1.3.3", | ||
"can-simple-observable": "^2.0.0" | ||
@@ -54,4 +40,2 @@ }, | ||
"can-observation": "^4.0.0", | ||
"cssify": "^0.6.0", | ||
"documentjs": "^0.4.2", | ||
"jshint": "^2.9.1", | ||
@@ -58,0 +42,0 @@ "steal": "^1.0.0", |
@@ -17,21 +17,22 @@ # can-define-backup | ||
``` | ||
var recipe = new DefineMap({ | ||
var recipe = new DefineMap.extend({ | ||
title: "Pancake Mix", | ||
yields: "3 batches", | ||
ingredients: [{ | ||
ingredient: "flour", | ||
quantity: "6 cups" | ||
},{ | ||
ingredient: "baking soda", | ||
quantity: "1 1/2 teaspoons" | ||
},{ | ||
ingredient: "baking powder", | ||
quantity: "3 teaspoons" | ||
},{ | ||
ingredient: "salt", | ||
quantity: "1 tablespoon" | ||
},{ | ||
ingredient: "sugar", | ||
quantity: "2 tablespoons" | ||
}] | ||
ingredients: { | ||
default: () => [{ | ||
ingredient: "flour", | ||
quantity: "6 cups" | ||
},{ | ||
ingredient: "baking soda", | ||
quantity: "1 1/2 teaspoons" | ||
},{ | ||
ingredient: "baking powder", | ||
quantity: "3 teaspoons" | ||
},{ | ||
ingredient: "salt", | ||
quantity: "1 tablespoon" | ||
},{ | ||
ingredient: "sugar", | ||
quantity: "2 tablespoons" | ||
}] | ||
}); | ||
@@ -38,0 +39,0 @@ defineBackup(recipe); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6
207
117
21584
15
1
+ Addedcan-diff@<2.0.0
- Removedcan-set@^1.3.3
- Removedcan-ajax@1.4.1(transitive)
- Removedcan-deparam@1.2.3(transitive)
- Removedcan-dom-data-state@0.2.0(transitive)
- Removedcan-event-dom-enter@1.0.4(transitive)
- Removedcan-event-dom-radiochange@1.0.5(transitive)
- Removedcan-param@1.2.0(transitive)
- Removedcan-parse-uri@1.2.2(transitive)
- Removedcan-set@1.6.0(transitive)
- Removedcan-types@1.4.0(transitive)
- Removedcan-util@3.14.0(transitive)