Comparing version
@@ -12,2 +12,3 @@ var __defProp$1 = Object.defineProperty; | ||
}; | ||
const OPS = ["Value", "Copy", "Blank", "ReturnIntoArray", "ReturnIntoObject", "ReturnIntoObjectSameKey", "PushField", "PushElement", "PushParent", "Pop", "PushFieldCopy", "PushFieldBlank", "PushElementCopy", "PushElementBlank", "ReturnIntoObjectPop", "ReturnIntoObjectSameKeyPop", "ReturnIntoArrayPop", "ObjectSetFieldValue", "ObjectCopyField", "ObjectDeleteField", "ArrayAppendValue", "ArrayAppendSlice", "StringAppendString", "StringAppendSlice"]; | ||
class Patcher { | ||
@@ -21,3 +22,2 @@ constructor(model, root, patch) { | ||
__publicField$1(this, "outputStack"); | ||
__publicField$1(this, "ops"); | ||
this.model = model; | ||
@@ -29,3 +29,2 @@ this.root = root; | ||
this.outputStack = []; | ||
this.ops = [this.processValue, this.processCopy, this.processBlank, this.processReturnIntoArray, this.processReturnIntoObject, this.processReturnIntoObjectSameKey, this.processPushField, this.processPushElement, this.processPushParent, this.processPop, this.processPushFieldCopy, this.processPushFieldBlank, this.processPushElementCopy, this.processPushElementBlank, this.processReturnIntoObjectPop, this.processReturnIntoObjectSameKeyPop, this.processReturnIntoArrayPop, this.processObjectSetFieldValue, this.processObjectCopyField, this.processObjectDeleteField, this.processArrayAppendValue, this.processArrayAppendSlice, this.processStringAppendString, this.processStringAppendSlice]; | ||
} | ||
@@ -44,7 +43,6 @@ read() { | ||
let opcode = this.read(); | ||
let op = this.ops[opcode]; | ||
if (!op) { | ||
throw new Error("Unknown opcode: ".concat(opcode)); | ||
} | ||
op.apply(this); | ||
let op = OPS[opcode]; | ||
if (!op) throw new Error("Unknown opcode: ".concat(opcode)); | ||
let processor = "process".concat(op); | ||
this[processor].apply(this); | ||
} | ||
@@ -143,5 +141,2 @@ let entry = this.outputStack.pop(); | ||
} | ||
processPushParent() { | ||
throw new Error("not implemented"); | ||
} | ||
processPushElement() { | ||
@@ -148,0 +143,0 @@ let idx = this.read(); |
{ | ||
"name": "mendoza", | ||
"version": "3.0.3-canary.0", | ||
"version": "3.0.3", | ||
"description": "Mendoza, differ for structured documents", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import {ObjectModel} from './object-model' | ||
import {RawPatch} from './patch' | ||
const OPS = [ | ||
'Value', | ||
'Copy', | ||
'Blank', | ||
'ReturnIntoArray', | ||
'ReturnIntoObject', | ||
'ReturnIntoObjectSameKey', | ||
'PushField', | ||
'PushElement', | ||
'PushParent', | ||
'Pop', | ||
'PushFieldCopy', | ||
'PushFieldBlank', | ||
'PushElementCopy', | ||
'PushElementBlank', | ||
'ReturnIntoObjectPop', | ||
'ReturnIntoObjectSameKeyPop', | ||
'ReturnIntoArrayPop', | ||
'ObjectSetFieldValue', | ||
'ObjectCopyField', | ||
'ObjectDeleteField', | ||
'ArrayAppendValue', | ||
'ArrayAppendSlice', | ||
'StringAppendString', | ||
'StringAppendSlice', | ||
] | ||
type InputEntry<V> = { | ||
@@ -22,3 +49,2 @@ value: V | ||
outputStack: OutputEntry<V, S, O, A>[] | ||
ops: ((this: Patcher<V, S, O, A>) => void)[] | ||
@@ -32,28 +58,2 @@ constructor(model: ObjectModel<V, S, O, A>, root: V, patch: RawPatch) { | ||
this.outputStack = [] | ||
this.ops = [ | ||
this.processValue, | ||
this.processCopy, | ||
this.processBlank, | ||
this.processReturnIntoArray, | ||
this.processReturnIntoObject, | ||
this.processReturnIntoObjectSameKey, | ||
this.processPushField, | ||
this.processPushElement, | ||
this.processPushParent, | ||
this.processPop, | ||
this.processPushFieldCopy, | ||
this.processPushFieldBlank, | ||
this.processPushElementCopy, | ||
this.processPushElementBlank, | ||
this.processReturnIntoObjectPop, | ||
this.processReturnIntoObjectSameKeyPop, | ||
this.processReturnIntoArrayPop, | ||
this.processObjectSetFieldValue, | ||
this.processObjectCopyField, | ||
this.processObjectDeleteField, | ||
this.processArrayAppendValue, | ||
this.processArrayAppendSlice, | ||
this.processStringAppendString, | ||
this.processStringAppendSlice, | ||
] | ||
} | ||
@@ -71,7 +71,6 @@ | ||
let opcode = this.read() as number | ||
let op = this.ops[opcode] | ||
if (!op) { | ||
throw new Error(`Unknown opcode: ${opcode}`) | ||
} | ||
op.apply(this) | ||
let op = OPS[opcode] | ||
if (!op) throw new Error(`Unknown opcode: ${opcode}`) | ||
let processor = `process${op}` | ||
;(this as any)[processor].apply(this) | ||
} | ||
@@ -185,6 +184,2 @@ | ||
processPushParent() { | ||
throw new Error('not implemented') | ||
} | ||
processPushElement() { | ||
@@ -191,0 +186,0 @@ let idx = this.read() as number |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
-100%167520
-1.53%2265
-0.74%