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

gedi

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gedi - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

154

gedi.js

@@ -244,8 +244,8 @@ //Copyright (C) 2012 Kory Nunn

function getSourcePathInfo(expression, parentPath, subPathOpperation){
var scope = {
_gmc_: parentPath
},
function getSourcePathInfo(expression, parentPath, scope, subPathOpperation){
var scope = scope || {},
path;
scope._gmc_ = parentPath;
var resultToken = gel.evaluate(expression, scope, true)[0],

@@ -272,38 +272,37 @@ sourcePathInfo = resultToken.sourcePathInfo;

function modelSet(expression, value, parentPath, dirty) {
if(typeof expression === 'object' && !paths.create(expression)){
dirty = value;
value = expression;
expression = paths.createRoot();
}else if(typeof parentPath === 'boolean'){
dirty = parentPath;
parentPath = undefined;
}
if(expression && !arguments[4]){
getSourcePathInfo(expression, parentPath, function(subPath){
modelSet(subPath, value, parentPath, dirty, true);
});
return;
}
function modelSetPath(path, value, parentPath, dirty, scope){
parentPath = parentPath || paths.create();
expression = paths.resolve(parentPath, expression);
path = paths.resolve(parentPath, path);
setDirtyState(expression, dirty);
setDirtyState(path, dirty);
var previousValue = get(expression, model);
var previousValue = get(path, model);
var keysChanged = set(expression, value, model);
var keysChanged = set(path, value, model);
if(!(value instanceof DeletedItem)){
events.addModelReference(expression, value);
events.trigger(expression, keysChanged);
events.addModelReference(path, value);
events.trigger(path, keysChanged);
}
if(!(value && typeof value !== 'object') && previousValue && typeof previousValue === 'object'){
events.removeModelReference(expression, previousValue);
events.removeModelReference(path, previousValue);
}
}
function modelSet(expression, value, parentPath, dirty, scope) {
if(typeof expression === 'object' && !paths.create(expression)){
dirty = value;
value = expression;
expression = paths.createRoot();
}else if(typeof parentPath === 'boolean'){
dirty = parentPath;
parentPath = undefined;
}
getSourcePathInfo(expression, parentPath, scope, function(subPath){
modelSetPath(subPath, value, parentPath, dirty, scope);
});
}
//***********************************************

@@ -315,3 +314,3 @@ //

function modelRemove(expression, parentPath, dirty) {
function modelRemove(expression, parentPath, dirty, scope) {
if(parentPath instanceof Boolean){

@@ -322,57 +321,37 @@ dirty = parentPath;

if(expression && !arguments[3]){
itemParentPaths = {};
getSourcePathInfo(expression, parentPath, function(subPath){
modelSet(subPath, new DeletedItem(), parentPath, dirty, true);
itemParentPaths[paths.append(subPath, paths.create(pathConstants.upALevel))] = null;
});
itemParentPaths = {};
getSourcePathInfo(expression, parentPath, scope, function(subPath){
modelSetPath(subPath, new DeletedItem(), parentPath, dirty, scope);
itemParentPaths[paths.append(subPath, paths.create(pathConstants.upALevel))] = null;
});
for(var key in itemParentPaths){
if(itemParentPaths.hasOwnProperty(key)){
var itemParentPath = paths.resolve(parentPath || paths.createRoot(), key),
parentObject = get(itemParentPath, model),
isArray = Array.isArray(parentObject);
for(var key in itemParentPaths){
if(itemParentPaths.hasOwnProperty(key)){
var itemParentPath = paths.resolve(parentPath || paths.createRoot(), key),
parentObject = get(itemParentPath, model),
isArray = Array.isArray(parentObject);
if(isArray){
var anyRemoved;
for(var i = 0; i < parentObject.length; i++){
if(parentObject[i] instanceof DeletedItem){
parentObject.splice(i, 1);
i--;
anyRemoved = true;
}
if(isArray){
var anyRemoved;
for(var i = 0; i < parentObject.length; i++){
if(parentObject[i] instanceof DeletedItem){
parentObject.splice(i, 1);
i--;
anyRemoved = true;
}
if(anyRemoved){
events.trigger(itemParentPath);
}
}
// Always run keys version, because array's might have non-index keys
for(var key in parentObject){
if(parentObject[key] instanceof DeletedItem){
delete parentObject[key];
events.trigger(paths.append(itemParentPath, key));
}
if(anyRemoved){
events.trigger(itemParentPath);
}
}
// Always run keys version, because array's might have non-index keys
for(var key in parentObject){
if(parentObject[key] instanceof DeletedItem){
delete parentObject[key];
events.trigger(paths.append(itemParentPath, key));
}
}
}
return;
}
parentPath = parentPath || paths.create();
expression = paths.resolve(parentPath, expression);
setDirtyState(expression, dirty);
var removedItem = get(expression, model),
parentObject = remove(expression, model);
if(Array.isArray(parentObject)){
//trigger one above
events.trigger(paths.resolve(paths.createRoot(), paths.append(expression, pathConstants.upALevel)));
}else{
events.trigger(expression);
}
events.removeModelReference(expression, removedItem);
}

@@ -386,14 +365,5 @@

function setDirtyState(expression, dirty, parentPath) {
function setPathDirtyState(path, dirty, parentPath, scope){
var reference = dirtyModel;
if(expression && !arguments[3]){
getSourcePathInfo(expression, parentPath, function(subPath){
setDirtyState(subPath, dirty, parentPath, true);
});
return;
}
if(!paths.create(expression)){
if(!paths.create(path)){
throw exceptions.invalidPath;

@@ -407,3 +377,3 @@ }

if(paths.isRoot(expression)){
if(paths.isRoot(path)){
dirtyModel = {

@@ -417,7 +387,7 @@ '_isDirty_': dirty

if(paths.isAbsolute(expression)){
if(paths.isAbsolute(path)){
index = 1;
}
var pathParts = paths.toParts(paths.resolve(parentPath, expression));
var pathParts = paths.toParts(paths.resolve(parentPath, path));

@@ -443,2 +413,8 @@ for(; index < pathParts.length; index++){

function setDirtyState(expression, dirty, parentPath, scope) {
getSourcePathInfo(expression, parentPath, scope, function(subPath){
setPathDirtyState(subPath, dirty, parentPath, scope);
});
}
//***********************************************

@@ -445,0 +421,0 @@ //

@@ -5,3 +5,3 @@ {

"author": "Kory Nunn <knunn187@gmail.com>",
"version": "1.4.1",
"version": "1.5.0",
"main": "gedi.js",

@@ -8,0 +8,0 @@ "dependencies": {

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