8000 Auto-generated commit · stdlib-js/utils-async-compose@5581a63 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5581a63

Browse files
committed
Auto-generated commit
1 parent 5d6ed2b commit 5581a63

File tree

5 files changed

+17
-272
lines changed

5 files changed

+17
-272
lines changed

.github/.keepalive

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-11-01T01:05:40.810Z

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

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/dist/test.js

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

2323
var tape = require( 'tape' );
24-
var noop = require( '@stdlib/utils-noop' );
25-
var composeAsync = require( './../../dist' );
24+
var main = require( './../../dist' );
2625

2726

2827
// TESTS //
2928

30-
tape( 'main export is a function', function test( t ) {
29+
tape( 'main export is defined', function test( t ) {
3130
t.ok( true, __filename );
32-
t.strictEqual( typeof composeAsync, 'function', 'main export is a function' );
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
3332
t.end();
3433
});
35-
36-
tape( 'the function throws an error if not provided multiple functions to compose', function test( t ) {
37-
t.throws( foo, Error, 'throws an error' );
38-
t.throws( bar, Error, 'throws an error' );
39-
t.end();
40-
41-
function foo() {
42-
composeAsync();
43-
}
44-
45-
function bar() {
46-
composeAsync( noop );
47-
}
48-
});
49-
50-
tape( 'the function throws an error if not provided a function', function test( t ) {
51-
var values;
52-
var i;
53-
54-
values = [
55-
'5',
56-
5,
57-
NaN,
58-
null,
59-
void 0,
60-
true,
61-
[],
62-
{}
63-
];
64-
65-
for ( i = 0; i < values.length; i++ ) {
66-
t.throws( badValue1( values[i] ), TypeError, 'throws an error when provided '+values[i] );
67-
t.throws( badValue2( values[i] ), TypeError, 'throws an error when provided '+values[i] );
68-
t.throws( badValue3( values[i] ), TypeError, 'throws an error when provided '+values[i] );
69-
}
70-
t.end();
71-
72-
function badValue1( value ) {
73-
return function badValue() {
74-
composeAsync( value, noop );
75-
};
76-
}
77-
78-
function badValue2( value ) {
79-
return function badValue() {
80-
composeAsync( noop, value );
81-
};
82-
}
83-
84-
function badValue3( value ) {
85-
return function badValue() {
86-
composeAsync( noop, noop, value );
87-
};
88-
}
89-
});
90-
91-
tape( 'the function returns a function', function test( t ) {
92-
var fcn = composeAsync( noop, noop );
93-
t.strictEqual( typeof fcn, 'function', 'returns a function' );
94-
t.end();
95-
});
96-
97-
tape( 'the function returns a composite function', function test( t ) {
98-
var f;
99-
100-
function a( x, next ) {
101-
setTimeout( onTimeout, 0 );
102-
function onTimeout() {
103-
next( null, x*3 );
104-
}
105-
}
106-
107-
function b( z, next ) {
108-
setTimeout( onTimeout, 0 );
109-
function onTimeout() {
110-
next( null, z+5 );
111-
}
112-
}
113-
114-
function c( r, next ) {
115-
setTimeout( onTimeout, 0 );
116-
function onTimeout() {
117-
next( null, r/10 );
118-
}
119-
}
120-
121-
f = composeAsync( c, b, a );
122-
f( 5, done );
123-
124-
function done( error, v ) {
125-
if ( error ) {
126-
t.fail( error.message );
127-
} else {
128-
t.strictEqual( v, 2, 'returns composite result' );
129-
}
130-
t.end();
131-
}
132-
});
133-
134-
tape( 'the composite function supports providing a rightmost multi-parameter function', function test( t ) {
135-
var f;
136-
137-
function a( x, y, next ) {
138-
setTimeout( onTimeout, 0 );
139-
function onTimeout() {
140-
next( null, x*y );
141-
}
142-
}
143-
144-
function b( z, next ) {
145-
setTimeout( onTimeout, 0 );
146-
function onTimeout() {
147-
next( null, z+5 );
148-
}
149-
}
150-
151-
function c( r, next ) {
152-
setTimeout( onTimeout, 0 );
153-
function onTimeout() {
154-
next( null, r/10 );
155-
}
156-
}
157-
158-
f = composeAsync( c, b, a );
159-
f( 5, 3, done );
160-
161-
function done( error, v ) {
162-
if ( error ) {
163-
t.fail( error.message );
164-
} else {
165-
t.strictEqual( v, 2, 'returns composite result' );
166-
}
167-
t.end();
168-
}
169-
});
170-
171-
tape( 'if an error is encountered while invoking a composed function, the composite function suspends execution and immediately returns the error', function test( t ) {
172-
var count;
173-
var f;
174-
175-
function a( x, next ) {
176-
setTimeout( onTimeout, 0 );
177-
function onTimeout() {
178-
count += 1;
179-
next( new Error( 'beep' ) );
180-
}
181-
}
182-
183-
function b( z, next ) {
184-
setTimeout( onTimeout, 0 );
185-
function onTimeout() {
186-
count += 1;
187-
next( null, z+5 );
188-
}
189-
}
190-
191-
function c( r, next ) {
192-
setTimeout( onTimeout, 0 );
193-
function onTimeout() {
194-
count += 1;
195-
next( null, r/10 );
196-
}
197-
}
198-
199-
f = composeAsync( c, b, a );
200-
count = 0;
201-
f( 5, done );
202-
203-
function done( error ) {
204-
if ( error ) {
205-
t.pass( error.message );
206-
} else {
207-
t.fail( 'should return an error' );
208-
}
209-
t.strictEqual( count, 1, 'invokes expected number of functions' );
210-
t.end();
211-
}
212-
});
213-
214-
tape( 'if an error is encountered while invoking a composed function, the composite function suspends execution and immediately returns the error', function test( t ) {
215-
var count;
216-
var f;
217-
218-
function a( x, next ) {
219-
setTimeout( onTimeout, 0 );
220-
function onTimeout() {
221-
count += 1;
222-
next( null, x*3 );
223-
}
224-
}
225-
226-
function b( z, next ) {
227-
setTimeout( onTimeout, 0 );
228-
function onTimeout() {
229-
count += 1;
230-
next( new Error( 'beep' ) );
231-
}
232-
}
233-
234-
function c( r, next ) {
235-
setTimeout( onTimeout, 0 );
236-
function onTimeout() {
237-
count += 1;
238-
next( null, r/10 );
239-
}
240-
}
241-
242-
f = composeAsync( c, b, a );
243-
count = 0;
244-
f( 5, done );
245-
246-
function done( error ) {
247-
if ( error ) {
248-
t.pass( error.message );
249-
} else {
250-
t.fail( 'should return an error' );
251-
}
252-
t.strictEqual( count, 2, 'invokes expected number of functions' );
253-
t.end();
254-
}
255-
});
256-
257-
tape( 'if an error is encountered while invoking a composed function, the composite function suspends execution and immediately returns the error', function test( t ) {
258-
var count;
259-
var f;
260-
261-
function a( x, next ) {
262-
setTimeout( onTimeout, 0 );
263-
function onTimeout() {
264-
count += 1;
265-
next( null, x*3 );
266-
}
267-
}
268-
269-
function b( z, next ) {
270-
setTimeout( onTimeout, 0 );
271-
function onTimeout() {
272-
count += 1;
273-
next( null, z+5 );
274-
}
275-
}
276-
277-
function c( r, next ) {
278-
setTimeout( onTimeout, 0 );
279-
function onTimeout() {
280-
count += 1;
281-
next( new Error( 'beep' ) );
282-
}
283-
}
284-
285-
f = composeAsync( c, b, a );
286-
count = 0;
287-
f( 5, done );
288-
289-
function done( error ) {
290-
if ( error ) {
291-
t.pass( error.message );
292-
} else {
293-
t.fail( 'should return an error' );
294-
}
295-
t.strictEqual( count, 3, 'invokes expected number of functions' );
296-
t.end();
297-
}
298-
});

0 commit comments

Comments
 (0)
0