Skip to content

Commit 2acd65b

Browse files
committed
refactor: main loop and tests
--- 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: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 67b6a3a commit 2acd65b

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

lib/node_modules/@stdlib/array/base/pluck/lib/assign.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function internal( x, prop, out, stride, offset ) {
6363
var v;
6464

6565
io = offset;
66-
for ( i = 0; i < x.length; i++ ) {
66+
for ( i = 0; i < out.length; i++ ) {
6767
v = x[ i ];
6868
if (
6969
v !== void 0 &&
@@ -124,7 +124,7 @@ function accessors( x, prop, out, stride, offset ) {
124124
oset = out.accessors[ 1 ];
125125

126126
io = offset;
127-
for ( i = 0; i < xdata.length; i++ ) {
127+
for ( i = 0; i < odata.length; i++ ) {
128128
v = xget( xdata, i );
129129
if (
130130
v !== void 0 &&

lib/node_modules/@stdlib/array/base/pluck/test/test.assign.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var tape = require( 'tape' );
2424
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
25+
var zeros = require( '@stdlib/array/base/zeros' );
2526
var pluck = require( './../lib' ).assign;
2627

2728

@@ -50,7 +51,7 @@ tape( 'the function extracts property values from an input object array and assi
5051
'a': 3
5152
}
5253
];
53-
out = [ 0, 0, 0 ];
54+
out = zeros( x.length );
5455
expected = [ 1, 2, 3 ];
5556
actual = pluck( x, 'a', out, 1, 0 );
5657

@@ -76,15 +77,15 @@ tape( 'the function extracts property values from an input object array and assi
7677
'a': 3
7778
}
7879
];
79-
out = [ 0, 0, 0 ];
80+
out = zeros( x.length );
8081
expected = [ 1, 2, 3 ];
8182
actual = pluck( toAccessorArray( x ), 'a', out, 1, 0 );
8283

8384
t.deepEqual( actual, expected, 'returns expected value' );
8485
t.end();
8586
});
8687

87-
tape( 'the function supports providing a stride parameter', function test( t ) {
88+
tape( 'the function supports providing a `stride` parameter', function test( t ) {
8889
var expected;
8990
var actual;
9091
var out;
@@ -101,7 +102,7 @@ tape( 'the function supports providing a stride parameter', function test( t ) {
101102
'a': 3
102103
}
103104
];
104-
out = [ 0, 0, 0, 0, 0, 0 ];
105+
out = zeros( x.length * 2 );
105106
expected = [ 1, 0, 2, 0, 3, 0 ];
106107
actual = pluck( x, 'a', out, 2, 0 );
107108

@@ -110,7 +111,7 @@ tape( 'the function supports providing a stride parameter', function test( t ) {
110111
t.end();
111112
});
112113

113-
tape( 'the function supports providing an offset parameter', function test( t ) {
114+
tape( 'the function supports providing a negative `stride` parameter', function test( t ) {
114115
var expected;
115116
var actual;
116117
var out;
@@ -127,7 +128,33 @@ tape( 'the function supports providing an offset parameter', function test( t )
127128
'a': 3
128129
}
129130
];
130-
out = [ 0, 0, 0, 0, 0, 0 ];
131+
out = zeros( x.length );
132+
expected = [ 3, 2, 1 ];
133+
actual = pluck( x, 'a', out, -1, 2 );
134+
135+
t.strictEqual( actual, out, 'returns expected value' );
136+
t.deepEqual( actual, expected, 'returns expected value' );
137+
t.end();
138+
});
139+
140+
tape( 'the function supports providing an `offset` parameter', function test( t ) {
141+
var expected;
142+
var actual;
143+
var out;
144+
var x;
145+
146+
x = [
147+
{
148+
'a': 1
149+
},
150+
{
151+
'a': 2
152+
},
153+
{
154+
'a': 3
155+
}
156+
];
157+
out = zeros( x.length * 2 );
131158
expected = [ 0, 1, 0, 2, 0, 3 ];
132159
actual = pluck( x, 'a', out, 2, 1 );
133160

0 commit comments

Comments
 (0)