Skip to content

Commit

Permalink
AssetDatabase: allow a patch to have both instructions and subpatches
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Dec 29, 2024
1 parent 195ce07 commit 71f9c9f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/AssetDatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,23 +397,22 @@ class AssetDatabase {
}

applyPatchInstructions( patch, data ) {
if ( Array.isArray( patch[0] ) ) {
// This patch is an Array of patches, not a single patch (which is Array of instructions).
// Handle this recursively.
patch.forEach( ( subpatch ) => this.applyPatchInstructions( subpatch, data ) );
return;
}

// This is set to true if we find "test" operation that tells us to ignore the rest of this patch.
var patchSkipped = false;

// Single patch (array of instructions).
patch.forEach( ( instruction ) => {
if ( patchSkipped ) {
// This instruction must be ignored, because preceding "test" instruction says so.
return;
}

if ( Array.isArray( instruction ) ) {
// This is an array of instructions, not a single instruction.
// Handle this recursively.
this.applyPatchInstructions( instruction, data );
return;
}

var op = instruction.op,
value = instruction.value;

Expand Down

0 comments on commit 71f9c9f

Please sign in to comment.