bare-script 2.2.0 → 2.2.2

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 +6 -8
  2. package/package.json +2 -2
package/lib/library.js CHANGED
@@ -59,7 +59,7 @@ export const scriptFunctions = {
59
59
  // $arg value: The value to find in the array
60
60
  // $arg index: Optional (default is 0). The index at which to start the search.
61
61
  // $return: The first index of the value in the array; -1 if not found.
62
- 'arrayIndexOf': ([array, value, index = 0]) => (Array.isArray(array) ? array.indexOf(value, index) : null),
62
+ 'arrayIndexOf': ([array, value, index = 0]) => (Array.isArray(array) ? array.indexOf(value, index) : -1),
63
63
 
64
64
  // $function: arrayJoin
65
65
  // $group: Array
@@ -77,7 +77,7 @@ export const scriptFunctions = {
77
77
  // $arg index: Optional (default is the end of the array). The index at which to start the search.
78
78
  // $return: The last index of the value in the array; -1 if not found.
79
79
  'arrayLastIndexOf': ([array, value, index = null]) => (
80
- Array.isArray(array) ? (index === null ? array.lastIndexOf(value) : array.lastIndexOf(value, index)) : null
80
+ Array.isArray(array) ? (index === null ? array.lastIndexOf(value) : array.lastIndexOf(value, index)) : -1
81
81
  ),
82
82
 
83
83
  // $function: arrayLength
@@ -160,7 +160,7 @@ export const scriptFunctions = {
160
160
  // $group: Data
161
161
  // $doc: Aggregate a data array
162
162
  // $arg data: The data array
163
- // $arg aggregation: The [aggregation model](model.html#var.vName='Aggregation')
163
+ // $arg aggregation: The [aggregation model](https://craigahobbs.github.io/bare-script/library/model.html#var.vName='Aggregation')
164
164
  // $return: The aggregated data array
165
165
  'dataAggregate': ([data, aggregation]) => aggregateData(data, validateAggregation(aggregation)),
166
166
 
@@ -599,7 +599,7 @@ export const scriptFunctions = {
599
599
  // $arg defaultValue: The default value (optional)
600
600
  // $return: The value or null if the key does not exist
601
601
  'objectGet': ([object, key, defaultValue = null]) => (
602
- object !== null && typeof object === 'object' ? (Object.hasOwn(object, key) ? object[key] : defaultValue) : null
602
+ object !== null && typeof object === 'object' ? (Object.hasOwn(object, key) ? object[key] : defaultValue) : defaultValue
603
603
  ),
604
604
 
605
605
  // $function: objectHas
@@ -774,7 +774,7 @@ export const scriptFunctions = {
774
774
  // $arg searchString: The search string
775
775
  // $arg index: Optional (default is 0). The index at which to start the search.
776
776
  // $return: The first index of the search string; -1 if not found.
777
- 'stringIndexOf': ([string, searchString, index]) => (typeof string === 'string' ? string.indexOf(searchString, index) : null),
777
+ 'stringIndexOf': ([string, searchString, index]) => (typeof string === 'string' ? string.indexOf(searchString, index) : -1),
778
778
 
779
779
  // $function: stringLastIndexOf
780
780
  // $group: String
@@ -783,9 +783,7 @@ export const scriptFunctions = {
783
783
  // $arg searchString: The search string
784
784
  // $arg index: Optional (default is the end of the string). The index at which to start the search.
785
785
  // $return: The last index of the search string; -1 if not found.
786
- 'stringLastIndexOf': ([string, searchString, index]) => (
787
- typeof string === 'string' ? string.lastIndexOf(searchString, index) : null
788
- ),
786
+ 'stringLastIndexOf': ([string, searchString, index]) => (typeof string === 'string' ? string.lastIndexOf(searchString, index) : -1),
789
787
 
790
788
  // $function: stringLength
791
789
  // $group: String
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "2.2.0",
4
+ "version": "2.2.2",
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": "~8.0",
34
- "eslint": "~8.48",
34
+ "eslint": "~8.50",
35
35
  "jsdoc": "~4.0"
36
36
  }
37
37
  }