bare-script 3.0.12 → 3.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/library.js +21 -0
  2. package/package.json +2 -2
package/lib/library.js CHANGED
@@ -40,6 +40,26 @@ const arrayCopyArgs = valueArgsModel([
40
40
  ]);
41
41
 
42
42
 
43
+ // $function: arrayDelete
44
+ // $group: Array
45
+ // $doc: Delete an array element
46
+ // $arg array: The array
47
+ // $arg index: The index of the element to delete
48
+ function arrayDelete(args) {
49
+ const [array, index] = valueArgsValidate(arrayDeleteArgs, args);
50
+ if (index >= array.length) {
51
+ throw new ValueArgsError('index', index);
52
+ }
53
+
54
+ array.splice(index, 1);
55
+ }
56
+
57
+ const arrayDeleteArgs = valueArgsModel([
58
+ {'name': 'array', 'type': 'array'},
59
+ {'name': 'index', 'type': 'number', 'integer': true, 'gte': 0}
60
+ ]);
61
+
62
+
43
63
  // $function: arrayExtend
44
64
  // $group: Array
45
65
  // $doc: Extend one array with another
@@ -2057,6 +2077,7 @@ const urlEncodeComponentArgs = valueArgsModel([
2057
2077
  // The built-in script functions
2058
2078
  export const scriptFunctions = {
2059
2079
  arrayCopy,
2080
+ arrayDelete,
2060
2081
  arrayExtend,
2061
2082
  arrayGet,
2062
2083
  arrayIndexOf,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "3.0.12",
4
+ "version": "3.0.13",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "c8": "~10.1",
34
- "eslint": "~9.9",
34
+ "eslint": "~9.14",
35
35
  "jsdoc": "~4.0"
36
36
  }
37
37
  }