8000 Auto-generated commit · stdlib-js/utils-index-of@c0fc863 · GitHub
[go: up one dir, main page]

Skip to content

Commit c0fc863

Browse files
committed
Auto-generated commit
1 parent 39a4aa3 commit c0fc863

File tree

4 files changed

+16
-209
lines changed

4 files changed

+16
-209
lines changed

.github/.keepalive

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-11-01T02:53:25.049Z

.github/workflows/publish.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ jobs:
182182
fi
183183
# Trim leading and trailing whitespace:
184184
dep=$(echo "$dep" | xargs)
185-
version="^$(npm view $dep version)"
185+
version="$(npm view $dep version)"
186+
if [[ -z "$version" ]]; then
187+
continue
188+
fi
189+
version="^$version"
186190
jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp
187191
mv package.json.tmp package.json
188192
done
@@ -192,7 +196,11 @@ jobs:
192196
fi
193197
# Trim leading and trailing whitespace:
194198
dep=$(echo "$dep" | xargs)
195-
version="^$(npm view $dep version)"
199+
version="$(npm view $dep version)"
200+
if [[ -z "$version" ]]; then
201+
continue
202+
fi
203+
version="^$version"
196204
jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp
197205
mv package.json.tmp package.json
198206
done

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ Stephannie Jiménez Gacha <steff456@hotmail.com>
3737
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
3838
orimiles5 <97595296+orimiles5@users.noreply.github.com>
3939
rei2hu <reimu@reimu.ws>
40+
Robert Gislason <gztown2216@yahoo.com>

test/dist/test.js

Lines changed: 4 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,216 +21,13 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var indexOf = require( './../../dist' );
24+
var main = require( './../../dist' );
2525

2626

2727
// TESTS //
2828

29-
tape( 'main export is a function', function test( t ) {
29+
tape( 'main export is defined', function test( t ) {
3030
t.ok( true, __filename );
31-
t.strictEqual( typeof indexOf, 'function', 'main export is a function' );
32-
t.end();
33-
});
34-
35-
tape( 'the function throws a type error if not provided an array-like object', function test( t ) {
36-
var values;
37-
var i;
38-
39-
values = [
40-
5,
41-
NaN,
42-
true,
43-
null,
44-
void 0,
45-
{}, // not array-like, as no `length` property
46-
function noop() {} // has `length` property, but is a function
47-
];
48-
49-
for ( i = 0; i < values.length; i++ ) {
50-
t.throws( badValue( values[i] ), TypeError, 'throws type error when provided ' + values[ i ] );
51-
}
52-
t.end();
53-
54-
function badValue( value ) {
55-
return function badValue() {
56-
indexOf( value, 3 );
57-
};
58-
}
59-
});
60-
61-
tape( 'if provided a `fromIndex`, which is not an integer, the function throws a type error', function test( t ) {
62-
var values;
63-
var i;
64-
65-
values = [
66-
'5',
67-
5.234,
68-
NaN,
69-
true,
70-
null,
71-
void 0,
72-
{},
73-
[],
74-
function noop() {}
75-
];
76-
77-
for ( i = 0; i < values.length; i++ ) {
78-
t.throws( badValue( values[i] ), TypeError, 'throws type error when provided ' + values[ i ] );
79-
}
80-
t.end();
81-
82-
function badValue( value ) {
83-
return function badValue() {
84-
indexOf( [ 1, 2, 3 ], 3, value );
85-
};
86-
}
87-
});
88-
89-
tape( 'if provided an array-like object having length `0`, the function always returns `-1`', function test( t ) {
90-
var idx = indexOf( [], 5 );
91-
t.equal( idx, -1, 'returns -1' );
92-
t.end();
93-
});
94-
95-
tape( 'if provided a `fromIndex` which exceeds the input array length, the function always returns `-1`', function test( t ) {
96-
var idx = indexOf( [ 1, 2, 3 ], 2, 999999999999 );
97-
t.equal( idx, -1, 'returns -1' );
98-
t.end();
99-
});
100-
101-
tape( 'the function returns the first index at which a given element can be found', function test( t ) {
102-
var idx = indexOf( [ 1, 1, 1, 2, 2, 3, 3 ], 2 );
103-
t.equal( idx, 3, 'returns first occurrence index' );
104-
t.end();
105-
});
106-
107-
tape( 'the function supports finding `NaN` elements', function test( t ) {
108-
var idx = indexOf( [ 1, 1, 1, 2, NaN, 2, 3, NaN, 3 ], NaN );
109-
t.equal( idx, 4, 'returns first occurrence index' );
110-
t.end();
111-
});
112-
113-
tape( 'if a search element is not present, the function returns `-1`', function test( t ) {
114-
var idx = indexOf( [ 1, 2, 3 ], 4 );
115-
t.equal( idx, -1, 'returns -1' );
116-
t.end();
117-
});
118-
119-
tape( 'the function supports specifying a `fromIndex`', function test( t ) {
120-
var arr;
121-
var idx;
122-
123-
arr = [ 1, 1, 2, 1, 2, 2, 3, 2, 3 ];
124-
125-
idx = indexOf( arr, 2 );
126-
t.equal( idx, 2, 'returns first occurrence index' );
127-
128-
idx = indexOf( arr, 2, idx+1 );
129-
t.equal( idx, 4, 'returns second occurrence index' );
130-
131-
idx = indexOf( arr, 2, idx+1 );
132-
t.equal( idx, 5, 'returns third occurrence index' );
133-
134-
idx = indexOf( arr, 2, idx+1 );
135-
t.equal( idx, 7, 'returns fourth occurrence index' );
136-
137-
idx = indexOf( arr, 2, idx+1 );
138-
t.equal( idx, -1, 'returns -1' );
139-
140-
t.end();
141-
});
142-
143-
tape( 'if provided a `fromIndex` which is less than `0`, the function determines a start index relative to the last array element', function test( t ) {
144-
var arr;
145-
var idx;
146-
147-
arr = [ 1, 1, 2, 1, 2, 2, 3, 2, 3 ];
148-
149-
idx = indexOf( arr, 3, -1 );
150-
t.equal( idx, 8, 'returns last element index' );
151-
152-
idx = indexOf( arr, 2, -1 );
153-
t.equal( idx, -1, 'returns -1' );
154-
155-
idx = indexOf( arr, 2, -2 );
156-
t.equal( idx, 7, 'returns second to last element index' );
157-
158-
idx = indexOf( arr, 2, -3 );
159-
t.equal( idx, 7, 'returns second to last element index' );
160-
161-
idx = indexOf( arr, 2, -4 );
162-
t.equal( idx, 5, 'returns 5' );
163-
164-
t.end();
165-
});
166-
167-
tape( 'if provided a `fromIndex` which is less than `0` and whose absolute value exceeds the array length, the function starts searching from the first array element', function test( t ) {
168-
var arr;
169-
var idx;
170-
171-
arr = [ 1, 1, 2, 1, 2, 2, 3, 2, 3 ];
172-
173-
idx = indexOf( arr, 2, -99999999999999 );
174-
t.equal( idx, 2, 'returns first occurrence index' );
175-
176-
idx = indexOf( arr, 1, -99999999999999 );
177-
t.equal( idx, 0, 'returns first occurrence index' );
178-
179-
t.end();
180-
});
181-
182-
tape( 'the function supports searching `strings`', function test( t ) {
183-
var str;
184-
var idx;
185-
186-
str = 'bebop';
187-
idx = indexOf( str, 'o' );
188-
189-
t.equal( idx, 3, 'returns first occurrence index' );
190-
t.end();
191-
});
192-
193-
tape( 'the function supports array-like `objects`', function test( t ) {
194-
var obj;
195-
var idx;
196-
197-
obj = {
198-
'0': 'beep',
199-
'1': 'boop',
200-
'2': 'bap',
201-
'3': 'bop',
202-
'length': 4
203-
};
204-
205-
idx = indexOf( obj, 'bap' );
206-
207-
t.equal( idx, 2, 'returns first occurrence index' );
208-
t.end();
209-
});
210-
211-
tape( 'the function does not guarantee that only "own" properties are searched', function test( t ) {
212-
var foo;
213-
var idx;
214-
215-
function Foo() {
216-
this[ 0 ] = 'beep';
217-
this[ 1 ] = 'boop';
218-
this[ 2 ] = 'woot';
219-
this[ 3 ] = 'bop';
220-
this.length = 4;
221-
return this;
222-
}
223-
Foo.prototype[ 2 ] = 'bap';
224-
225-
foo = new Foo();
226-
227-
idx = indexOf( foo, 'bap' ) 7CB5 ;
228-
t.equal( idx, -1, 'returns -1' );
229-
230-
delete foo[ 2 ];
231-
232-
idx = indexOf( foo, 'bap' );
233-
t.equal( idx, 2, 'returns property on prototype' );
234-
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
23532
t.end();
23633
});

0 commit comments

Comments
 (0)
0