Skip to content

Commit

Permalink
append to array
Browse files Browse the repository at this point in the history
  • Loading branch information
jwklong committed Dec 3, 2024
1 parent 18a69d5 commit 2d43d59
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/extensions/jwArray/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ class Extension {
}
},
...jwArray.Block
},
{
opcode: 'append',
text: 'append [VALUE] to [ARRAY]',
arguments: {
ARRAY: jwArray.Argument,
VALUE: {
type: ArgumentType.STRING,
defaultValue: "foo",
exemptFromNormalization: true
}
},
...jwArray.Block
}
],
menus: {
Expand Down Expand Up @@ -278,6 +291,13 @@ class Extension {
ARRAY.array[clampIndex(Cast.toNumber(INDEX))-1] = VALUE
return ARRAY
}

append({ARRAY, VALUE}) {
ARRAY = jwArray.Type.toArray(ARRAY)

ARRAY.array.push(VALUE)
return ARRAY
}
}

module.exports = Extension

0 comments on commit 2d43d59

Please sign in to comment.