10000 Auto-generated commit · stdlib-js/utils-some-by-right@5cd16b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5cd16b2

Browse files
committed
Auto-generated commit
1 parent f7ae6cf commit 5cd16b2

File tree

5 files changed

+17
-290
lines changed

5 files changed

+17
-290
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:52:33.675Z

.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>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@stdlib/types": "^0.1.0"
4545
},
4646
"devDependencies": {
47-
"@stdlib/array-float64": "^0.1.0",
47+
"@stdlib/array-float64": "^0.1.1",
4848
"@stdlib/assert-is-boolean": "^0.1.1",
4949
"@stdlib/bench": "^0.1.0",
5050
"@stdlib/math-base-assert-is-nan": "^0.1.1",

test/dist/test.js

Lines changed: 4 additions & 287 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,296 +21,13 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var noop = require( '@stdlib/utils-noop' );
25-
var Float64Array = require( '@stdlib/array-float64' );
26-
var someByRight = require( './../../dist' );
24+
var main = require( './../../dist' );
2725

2826

2927
// TESTS //
3028

31-
tape( 'main export is a function', function test( t ) {
29+
tape( 'main export is defined', function test( t ) {
3230
t.ok( true, __filename );
33-
t.strictEqual( typeof someByRight, 'function', 'main export is a function' );
34-
t.end();
35-
});
36-
37-
tape( 'the function throws an error if not provided a collection', function test( t ) {
38-
var values;
39-
var i;
40-
41-
values = [
42-
'5',
43-
5,
44-
NaN,
45-
true,
46-
false,
47-
null,
48-
void 0,
49-
{},
50-
function noop() {},
51-
/.*/,
52-
new Date()
53-
];
54-
55-
for ( i = 0; i < values.length; i++ ) {
56-
t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
57-
}
58-
t.end();
59-
60-
function badValue( value ) {
61-
return function badValue() {
62-
someByRight( value, 1, noop );
63-
};
64-
}
65-
});
66-
67-
tape( 'the function throws an error if not provided a second argument which is a positive integer', function test( t ) {
68-
var values;
69-
var i;
70-
71-
values = [
72-
'5',
73-
-5,
74-
0,
75-
3.14,
76-
NaN,
77-
true,
78-
false,
79-
null,
80-
void 0,
81-
{},
82-
[],
83-
function noop() {}
84-
];
85-
86-
for ( i = 0; i < values.length; i++ ) {
87-
t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
88-
}
89-
t.end();
90-
91-
function badValue( value ) {
92-
return function badValue() {
93-
someByRight( [ 1, 2, 3 ], value, noop );
94-
};
95-
}
96-
});
97-
98-
tape( 'the function throws an error if not provided a predicate function', function test( t ) {
99-
var values;
100-
var i;
101-
102-
values = [
103-
'5',
104-
5,
105-
NaN,
106-
true,
107-
false,
108-
null,
109-
void 0,
110-
{},
111-
[],
112-
/.*/,
113-
new Date()
114-
];
115-
116-
for ( i = 0; i < values.length; i++ ) {
117-
t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
118-
}
119-
t.end();
120-
121-
function badValue( value ) {
122-
return function badValue() {
123-
someByRight( [ 1, 2, 3 ], 2, value );
124-
};
125-
}
126-
});
127-
128-
tape( 'if provided an empty collection, the function returns `false`', function test( t ) {
129-
var bool;
130-
var arr;
131-
132-
function foo() {
133-
t.fail( 'should not be invoked' );
134-
}
135-
arr = [];
136-
bool = someByRight( arr, 1, foo );
137-
138-
t.strictEqual( bool, false, 'returns false' );
139-
t.end();
140-
});
141-
142-
tape( 'the function returns `true` if a collection contains at least `n` elements which pass a test (array)', function test( t ) {
143-
var bool;
144-
var arr;
145-
146-
arr = [ -1, 1, -2, 3 ];
147-
148-
function isNegative( value ) {
149-
return ( value < 0 );
150-
}
151-
152-
bool = someByRight( arr, 2, isNegative );
153-
154-
t.strictEqual( bool, true, 'returns true' );
155-
t.end();
156-
});
157-
158-
tape( 'the function returns `false` if a collection does not contain at least `n` elements which pass a test (array)', function test( t ) {
159-
var bool;
160-
var arr;
161-
162-
arr = [ -1, -2, -3 ];
163-
164-
function isPositive( value ) {
165-
return ( value > 0 );
166-
}
167-
168-
bool = someByRight( arr, 1, isPositive );
169-
170-
t.strictEqual( bool, false, 'returns false' );
171-
t.end();
172-
});
173-
174-
tape( 'the function returns `true` if a collection contains at least `n` elements which pass a test (array-like object)', function test( t ) {
175-
var bool;
176-
var arr;
177-
178-
arr = {
179-
'length': 4,
180-
'0': -1,
181-
'1': 2,
182-
'2': -3,
183-
'3': 4
184-
};
185-
186-
function isNegative( value ) {
187-
return ( value < 0 );
188-
}
189-
190-
bool = someByRight( arr, 2, isNegative );
191-
192-
t.strictEqual( bool, true, 'returns true' );
193-
t.end();
194-
});
195-
196-
tape( 'the function returns `false` if a collection does not contain at least `n` elements which pass a test (array-like object)', function test( t ) {
197-
var bool;
198-
var arr;
199-
200-
arr = {
201-
'length': 3,
202-
'0': -1,
203-
'1': -2,
204-
'2': -3
205-
};
206-
207-
function isPositive( value ) {
208-
return ( value > 0 );
209-
}
210-
211-
bool = someByRight( arr, 1, isPositive );
212-
213-
t.strictEqual( bool, false, 'returns false' );
214-
t.end();
215-
});
216-
217-
tape( 'the function returns `true` if a collection contains at least `n` elements which pass a test (typed array)', function test( t ) {
218-
var bool;
219-
var arr;
220-
221-
arr = new Float64Array( [ -1.0, -2.0, -3.0, 4.0 ] );
222-
223-
function isNegative( value ) {
224-
return ( value < 0 );
225-
}
226-
227-
bool = someByRight( arr, 3, isNegative );
228-
229-
t.strictEqual( bool, true, 'returns true' );
230-
t.end();
231-
});
232-
233-
tape( 'the function returns `false` if a collection does not contain at least `n` elements which pass a test (typed array)', function test( t ) {
234-
var bool;
235-
var arr;
236-
237-
arr = new Float64Array( [ -1.0, -2.0, -3.0 ] );
238-
239-
function isPositive( value ) {
240-
return ( value > 0 );
241-
}
242-
243-
bool = someByRight( arr, 1, isPositive );
244-
245-
t.strictEqual( bool, false, 'returns false' );
246-
t.end();
247-
});
248-
249-
tape( 'the function supports providing an execution context', function test( t ) {
250-
var bool;
251-
var ctx;
252-
var arr;
253-
254-
function sum( value ) {
255-
/* eslint-disable no-invalid-this */
256-
this.sum += value;
257-
this.count += 1;
258-
return ( value < 0 );
259-
}
260-
261-
ctx = {
262-
'sum': 0,
263-
'count': 0
264-
};
265-
arr = [ -1.0, 2.0, -3.0, 1.0 ];
266-
267-
bool = someByRight( arr, 2, sum, ctx );
268-
269-
t.strictEqual( bool, true, 'returns true' );
270-
t.strictEqual( ctx.sum/ctx.count, -0.25, 'expected result' );
271-
272-
t.end();
273-
});
274-
275-
tape( 'the function provides basic support for dynamic arrays', function test( t ) {
276-
var bool;
277-
var arr;
278-
279-
arr = [ 1, 2, 3 ];
280-
281-
function isNegative( value, index, collection ) {
282-
if ( index === 0 ) {
283-
collection.unshift( value-1 );
284-
}
285-
return ( value < 0 );
286-
}
287-
288-
bool = someByRight( arr, 1, isNegative );
289-
290-
t.deepEqual( arr, [ -2, -1, 0, 1, 2, 3 ], 'expected result' );
291-
t.strictEqual( bool, true, 'returns true' );
292-
293-
t.end();
294-
});
295-
296-
tape( 'the function does not skip empty elements', function test( t ) {
297-
var expected;
298-
var bool;
299-
var arr;
300-
var i;
301-
302-
arr = [ -1, 1, , , 4 ]; // eslint-disable-line no-sparse-arrays
303-
expected = [ 4, void 0, void 0, 1, -1 ];
304-
i = -1;
305-
306-
function verify( value ) {
307-
i += 1;
308-
t.strictEqual( value, expected[ i ], 'provides expected value' );
309-
return ( value < 0 );
310-
}
311-
312-
bool = someByRight( arr, 1, verify );
313-
314-
t.strictEqual( bool, true, 'returns true' );
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
31532
t.end();
31633
});

0 commit comments

Comments
 (0)
0