Skip to content

Commit a1c44de

Browse files
committed
refactor: update type inference and docs and add test assertions
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - 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: passed - task: lint_license_headers status: passed ---
1 parent c03d88b commit a1c44de

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/node_modules/@stdlib/ndarray/with/docs/repl.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
{{alias}}( x, indices, value )
3-
Returns an ndarray with element at specified indices replaced by a provided
4-
value.
3+
Returns a new ndarray with the element at a specified index replaced by a
4+
provided value.
55

66
Parameters
77
----------
88
x: ndarray
99
Input array.
1010

11-
indices: Collection<integer>
11+
indices: Array<integer>
1212
Indices of the value to replace.
1313

1414
value: any

lib/node_modules/@stdlib/ndarray/with/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { typedndarray } from '@stdlib/types/ndarray';
4747
* var v = out.get( 0, 0 );
4848
* // returns 5
4949
*/
50-
declare function ndarrayWith<T = unknown, U extends typedndarray<T> = typedndarray<T>>( x: U, indices: Array<number>, value: T ): U;
50+
declare function ndarrayWith<T = unknown, U extends typedndarray<T> = typedndarray<T>>( x: typedndarray<T>, indices: Array<number>, value: T ): U;
5151

5252

5353
// EXPORTS //

lib/node_modules/@stdlib/ndarray/with/docs/types/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import ndarrayWith = require( './index' );
2424

2525
// The function returns an ndarray...
2626
{
27-
ndarrayWith( array( [ [ 1, 2 ], [ 3, 4 ] ] ), [ 0, 0 ], 5 ); // $ExpectType ndarray
27+
ndarrayWith( array<number>( [ [ 1, 2 ], [ 3, 4 ] ] ), [ 0, 0 ], 5 ); // $ExpectType typedndarray<number>
2828
}
2929

3030
// The compiler throws an error if the function is provided a first argument which is not an ndarray...
@@ -41,7 +41,7 @@ import ndarrayWith = require( './index' );
4141

4242
// The compiler throws an error if the function is provided a second argument which is not an array of integers...
4343
{
44-
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
44+
var x = array<number>( [ [ 1, 2 ], [ 3, 4 ] ] );
4545

4646
ndarrayWith( x, [ '1' ], 5 );
4747
ndarrayWith( x, 1, 5 ); // $ExpectError
@@ -55,7 +55,7 @@ import ndarrayWith = require( './index' );
5555

5656
// The compiler throws an error if the function is provided an unsupported number of arguments...
5757
{
58-
const x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
58+
const x = array<number>( [ [ 1, 2 ], [ 3, 4 ] ] );
5959

6060
ndarrayWith(); // $ExpectError
6161
ndarrayWith( x, [ 0, 0 ] ); // $ExpectError

lib/node_modules/@stdlib/ndarray/with/test/test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ tape( 'the function throws an error if provided a second argument with out-of-bo
121121
}
122122
});
123123

124-
tape( 'the function returns an ndarray with element at specified indices replaced by a provided value', function test( t ) {
124+
tape( 'the function returns a new ndarray with the element at a specified index replaced by a provided value', function test( t ) {
125125
var out;
126126
var x;
127127

@@ -130,12 +130,15 @@ tape( 'the function returns an ndarray with element at specified indices replace
130130
});
131131

132132
out = ndarrayWith( x, [ 0, 0, 0 ], 1.0 );
133+
t.notEqual( out, x, 'returns expected value' );
133134
t.strictEqual( out.get( 0, 0, 0 ), 1.0, 'returns expected value' );
134135

135136
out = ndarrayWith( x, [ 1, 1, 1 ], 1.0 );
137+
t.notEqual( out, x, 'returns expected value' );
136138
t.strictEqual( out.get( 1, 1, 1 ), 1.0, 'returns expected value' );
137139

138140
out = ndarrayWith( x, [ 2, 2, 2 ], 1.0 );
141+
t.notEqual( out, x, 'returns expected value' );
139142
t.strictEqual( out.get( 2, 2, 2 ), 1.0, 'returns expected value' );
140143

141144
t.end();

0 commit comments

Comments
 (0)