@stdlib/utils-async-inmap-right 0.0.7 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,149 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2021 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import inmapRightAsync = require( './index' );
20
-
21
- const fcn = ( value: number, index: number, next: Function ): void => {
22
- next( null, value * index );
23
- };
24
-
25
- const done = ( error: Error | null ) => {
26
- if ( error ) {
27
- throw error;
28
- }
29
- };
30
-
31
-
32
- // TESTS //
33
-
34
- // The function returns void...
35
- {
36
- inmapRightAsync( [ 0, 1, 1 ], fcn, done ); // $ExpectType void
37
- inmapRightAsync( [ -1, 1, 2 ], fcn, done ); // $ExpectType void
38
- }
39
-
40
- // The compiler throws an error if the function is provided a first argument which is not a collection...
41
- {
42
- inmapRightAsync( 2, fcn, done ); // $ExpectError
43
- inmapRightAsync( false, fcn, done ); // $ExpectError
44
- inmapRightAsync( true, fcn, done ); // $ExpectError
45
- inmapRightAsync( {}, fcn, done ); // $ExpectError
46
- }
47
-
48
- // The compiler throws an error if the function is provided a second argument which is not a function...
49
- {
50
- inmapRightAsync( [ 1, 2, 3 ], 2, done ); // $ExpectError
51
- inmapRightAsync( [ 1, 2, 3 ], false, done ); // $ExpectError
52
- inmapRightAsync( [ 1, 2, 3 ], true, done ); // $ExpectError
53
- inmapRightAsync( [ 1, 2, 3 ], 'abc', done ); // $ExpectError
54
- inmapRightAsync( [ 1, 2, 3 ], {}, done ); // $ExpectError
55
- inmapRightAsync( [ 1, 2, 3 ], [], done ); // $ExpectError
56
- }
57
-
58
- // The compiler throws an error if the function is provided a last argument which is not a function having a supported signature...
59
- {
60
- inmapRightAsync( [ 1, 2, 3 ], fcn, 2 ); // $ExpectError
61
- inmapRightAsync( [ 1, 2, 3 ], fcn, false ); // $ExpectError
62
- inmapRightAsync( [ 1, 2, 3 ], fcn, true ); // $ExpectError
63
- inmapRightAsync( [ 1, 2, 3 ], fcn, 'abc' ); // $ExpectError
64
- inmapRightAsync( [ 1, 2, 3 ], fcn, {} ); // $ExpectError
65
- inmapRightAsync( [ 1, 2, 3 ], fcn, [] ); // $ExpectError
66
- inmapRightAsync( [ 1, 2, 3 ], fcn, ( x: number ): number => x ); // $ExpectError
67
- }
68
-
69
- // The compiler throws an error if the function is provided an invalid number of arguments...
70
- {
71
- inmapRightAsync(); // $ExpectError
72
- inmapRightAsync( [ 1, 2, 3 ] ); // $ExpectError
73
- inmapRightAsync( [ 1, 2, 3 ], fcn ); // $ExpectError
74
- inmapRightAsync( [ 1, 2, 3 ], {}, fcn, done, {} ); // $ExpectError
75
- }
76
-
77
- // Attached to main export is a `factory` method which returns a function...
78
- {
79
- inmapRightAsync.factory( fcn ); // $ExpectType FactoryFunction
80
- inmapRightAsync.factory( { 'series': true }, fcn ); // $ExpectType FactoryFunction
81
- }
82
-
83
- // The compiler throws an error if the `factory` method is provided an options argument which is not an object...
84
- {
85
- inmapRightAsync.factory( [], fcn ); // $ExpectError
86
- inmapRightAsync.factory( 123, fcn ); // $ExpectError
87
- inmapRightAsync.factory( 'abc', fcn ); // $ExpectError
88
- inmapRightAsync.factory( false, fcn ); // $ExpectError
89
- inmapRightAsync.factory( true, fcn ); // $ExpectError
90
- }
91
-
92
- // The compiler throws an error if the `factory` method is provided a last argument which is not a function...
93
- {
94
- inmapRightAsync.factory( {} ); // $ExpectError
95
- inmapRightAsync.factory( true ); // $ExpectError
96
- inmapRightAsync.factory( false ); // $ExpectError
97
- inmapRightAsync.factory( {}, 123 ); // $ExpectError
98
- inmapRightAsync.factory( {}, 'abc' ); // $ExpectError
99
- }
100
-
101
- // The compiler throws an error if the function returned by the `factory` method is provided invalid arguments...
102
- {
103
- const fcn1 = inmapRightAsync.factory( fcn );
104
- fcn1( 12, done ); // $ExpectError
105
- fcn1( true, done ); // $ExpectError
106
- fcn1( false, done ); // $ExpectError
107
- fcn1( {}, done ); // $ExpectError
108
-
109
- fcn1( [ 1, 2, 3 ], 12 ); // $ExpectError
110
- fcn1( [ 1, 2, 3 ], true ); // $ExpectError
111
- fcn1( [ 1, 2, 3 ], false ); // $ExpectError
112
- fcn1( [ 1, 2, 3 ], '5' ); // $ExpectError
113
- fcn1( [ 1, 2, 3 ], {} ); // $ExpectError
114
- fcn1( [ 1, 2, 3 ], [] ); // $ExpectError
115
- fcn1( [ 1, 2, 3 ], ( x: number ): number => x ); // $ExpectError
116
- }
117
-
118
- // The compiler throws an error if the function returned by the `factory` method is provided an unsupported number of arguments...
119
- {
120
- const fcn1 = inmapRightAsync.factory( fcn );
121
- fcn1(); // $ExpectError
122
- fcn1( [ 1, 2, 3 ] ); // $ExpectError
123
- fcn1( [ 1, 2, 3 ], done, {} ); // $ExpectError
124
- }
125
-
126
- // The compiler throws an error if the `factory` method is provided a `limit` option which is not a number...
127
- {
128
- inmapRightAsync.factory( { 'limit': '12' }, fcn ); // $ExpectError
129
- inmapRightAsync.factory( { 'limit': true }, fcn ); // $ExpectError
130
- inmapRightAsync.factory( { 'limit': false }, fcn ); // $ExpectError
131
- inmapRightAsync.factory( { 'limit': {} }, fcn ); // $ExpectError
132
- inmapRightAsync.factory( { 'limit': [] }, fcn ); // $ExpectError
133
- inmapRightAsync.factory( { 'limit': ( x: number ): number => x }, fcn ); // $ExpectError
134
- }
135
-
136
- // The compiler throws an error if the `factory` method is provided a `series` option which is not a boolean...
137
- {
138
- inmapRightAsync.factory( { 'series': '12' }, fcn ); // $ExpectError
139
- inmapRightAsync.factory( { 'series': 12 }, fcn ); // $ExpectError
140
- inmapRightAsync.factory( { 'series': {} }, fcn ); // $ExpectError
141
- inmapRightAsync.factory( { 'series': [] }, fcn ); // $ExpectError
142
- inmapRightAsync.factory( { 'series': ( x: number ): number => x }, fcn ); // $ExpectError
143
- }
144
-
145
- // The compiler throws an error if the `factory` method is provided an invalid number of arguments...
146
- {
147
- inmapRightAsync.factory(); // $ExpectError
148
- inmapRightAsync.factory( {}, fcn, {} ); // $ExpectError
149
- }