You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit refactors the implementation to rely on the same value
algorithm, rather than strict equality. Previously, we treated NaN
values as equal, which follows the same value algorithm; however,
we did not distinguish between signed zeros. This commit ensures
that we follow the same value algorithm fully.
BREAKING CHANGE: distinguish signed zeros
To migrate, users should normalize signed zeros before invoking
this function. Otherwise, users should use a different algorithm
which uses strict equality to determine "sameness" (e.g., a package
such as `@stdlib/array/base/includes`).
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/assert/contains/README.md
+16-7Lines changed: 16 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ limitations under the License.
18
18
19
19
-->
20
20
21
-
# Contains
21
+
# contains
22
22
23
23
> Test if an array-like value contains a search value.
24
24
@@ -36,16 +36,23 @@ limitations under the License.
36
36
var contains =require( '@stdlib/assert/contains' );
37
37
```
38
38
39
-
#### contains( val, searchValue\[, position] )
39
+
#### contains( value, searchValue\[, position] )
40
40
41
-
Tests if `val` contains a search value. When `val` is a `string`, the function checks whether the characters of a search string are found in the input string.
41
+
Tests if `value` contains a search value.
42
+
43
+
```javascript
44
+
var v =contains( [ 1, 2, 3 ], 2 );
45
+
// returns true
46
+
```
47
+
48
+
When `value` is a string, the function checks whether the characters of a search string are found in the input string.
42
49
43
50
```javascript
44
51
var v =contains( 'Hello World', 'World' );
45
52
// returns true
46
53
```
47
54
48
-
When `val` is an `array-like` object, but not a `string`, the function checks whether the input value contains an element strictly equal to the specified search value.
55
+
When `value` is an array-like object, but not a string, the function checks whether the input value contains an element which is the [same value][@stdlib/assert/is-same-value] as the specified search value.
If not provided an `array-like` object, the function throws an error.
87
+
If not provided an array-like object, the function throws an error.
81
88
82
89
<!-- run throws: true -->
83
90
@@ -105,8 +112,8 @@ var v = contains( 'hello', 'e', 2.5 );
105
112
106
113
## Notes
107
114
108
-
- For `strings`, the function is modeled after [String.prototype.includes][mdn-includes], part of the ECMAScript 6 specification. This function is different from a call to `String.prototype.includes.call` insofar as type-checking is performed for all arguments.
109
-
- The function does **not** distinguish between positive and negative zero.
115
+
- For strings, the function is modeled after [String.prototype.includes][mdn-includes], part of the ECMAScript 6 specification. This function is different from a call to `String.prototype.includes.call` insofar as type-checking is performed for all arguments.
116
+
- The function **does** distinguish between positive and negative zero (see [`@stdlib/assert/is-same-value`][@stdlib/assert/is-same-value].
110
117
- If `position < 0`, the search is performed for the entire input array or string.
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/assert/contains/docs/types/index.d.ts
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -27,13 +27,13 @@ import { ArrayLike } from '@stdlib/types/array';
27
27
*
28
28
* ## Notes
29
29
*
30
-
* - When `val` is a string, the function checks whether the characters of the search string are found in the input string. The search is case-sensitive.
31
-
* - When `val` is an array-like object, the function checks whether the input array contains an element strictly equal to the specified search value.
30
+
* - When `value` is a string, the function checks whether the characters of the search string are found in the input string. The search is case-sensitive.
31
+
* - When `value` is an array-like object, the function checks whether the input array contains an element which is the same as the specified search value.
32
32
* - For strings, this function is modeled after `String.prototype.includes`, part of the ECMAScript 6 specification. This function is different from a call to `String.prototype.includes.call` insofar as type-checking is performed for all arguments.
33
-
* - The function does not distinguish between positive and negative zero.
33
+
* - The function does distinguish between positive and negative zero.
34
34
* - If `position < 0`, the search is performed for the entire input array or string.
35
35
*
36
-
* @paramval - input value
36
+
* @paramvalue - input value
37
37
* @param searchValue - search value
38
38
* @param position - position at which to start searching for `searchValue` (default: 0)
39
39
* @throws second argument must be a primitive string primitive when the first argument is a string
@@ -67,7 +67,7 @@ import { ArrayLike } from '@stdlib/types/array';
0 commit comments