Skip to content

Commit 949ec7d

Browse files
committed
refactor: update to use slice/base/int2slice
1 parent b823b14 commit 949ec7d

File tree

2 files changed

+2
-61
lines changed

2 files changed

+2
-61
lines changed

lib/node_modules/@stdlib/slice/base/normalize-multi-slice/lib/error_out_of_bounds.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

lib/node_modules/@stdlib/slice/base/normalize-multi-slice/lib/main.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var args2multislice = require( '@stdlib/slice/base/args2multislice' );
2424
var Slice = require( '@stdlib/slice/ctor' );
2525
var normalizeSlice = require( '@stdlib/slice/base/normalize-slice' );
26-
var eOutOfBounds = require( './error_out_of_bounds.js' );
26+
var int2slice = require( '@stdlib/slice/base/int2slice' );
2727

2828

2929
// FUNCTIONS //
@@ -45,28 +45,7 @@ function normalize( value, len, strict ) {
4545
}
4646
// Case: integer
4747
if ( typeof value === 'number' ) {
48-
// If a value exceeds the last possible index, create an "empty" slice...
49-
if ( value >= len ) {
50-
if ( strict ) {
51-
return eOutOfBounds();
52-
}
53-
return new Slice( len, len, 1 );
54-
}
55-
// Check whether we need to resolve a slice relative to the last possible index...
56-
if ( value < 0 ) {
57-
value = len + value;
58-
59-
// If a value exceeds the first index, create an "empty" slice...
60-
if ( value < 0 ) {
61-
if ( strict ) {
62-
return eOutOfBounds();
63-
}
64-
return new Slice( 0, 0, 1 );
65-
}
66-
return new Slice( value, value+1, 1 ); // e.g., Slice( 2, 3, 1 ), which is the slice equivalent of only selecting the second row
67-
}
68-
// 0 <= s < N
69-
return new Slice( value, value+1, 1 );
48+
return int2slice( value, len, strict );
7049
}
7150
// Case: slice
7251
return normalizeSlice( value, len, strict );

0 commit comments

Comments
 (0)