New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

can-define-backup

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-define-backup - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0-pre.2

26

can-define-backup.js
//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);

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