@ohos-ports/stdlib-fs 0.0.0-stage → 0.4.1-beta.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.
Files changed (173) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +1 -0
  3. package/README.md +230 -2
  4. package/SECURITY.md +5 -0
  5. package/append-file/README.md +239 -0
  6. package/append-file/bin/cli +110 -0
  7. package/append-file/docs/repl.txt +72 -0
  8. package/append-file/docs/types/index.d.ts +133 -0
  9. package/append-file/docs/types/test.ts +193 -0
  10. package/append-file/docs/usage.txt +10 -0
  11. package/append-file/etc/cli_opts.json +22 -0
  12. package/append-file/lib/async.js +58 -0
  13. package/append-file/lib/index.js +61 -0
  14. package/append-file/lib/sync.js +58 -0
  15. package/append-file/package.json +69 -0
  16. package/close/README.md +172 -0
  17. package/close/docs/repl.txt +45 -0
  18. package/close/docs/types/index.d.ts +135 -0
  19. package/close/docs/types/test.ts +89 -0
  20. package/close/lib/index.js +73 -0
  21. package/close/lib/main.js +68 -0
  22. package/close/lib/sync.js +65 -0
  23. package/close/package.json +64 -0
  24. package/docs/types/index.d.ts +502 -0
  25. package/exists/README.md +252 -0
  26. package/exists/bin/cli +83 -0
  27. package/exists/docs/repl.txt +42 -0
  28. package/exists/docs/types/index.d.ts +112 -0
  29. package/exists/docs/types/test.ts +87 -0
  30. package/exists/docs/usage.txt +8 -0
  31. package/exists/etc/cli_opts.json +14 -0
  32. package/exists/lib/async.js +85 -0
  33. package/exists/lib/index.js +66 -0
  34. package/exists/lib/sync.js +62 -0
  35. package/exists/package.json +69 -0
  36. package/lib/index.js +186 -0
  37. package/open/README.md +204 -0
  38. package/open/docs/repl.txt +65 -0
  39. package/open/docs/types/index.d.ts +150 -0
  40. package/open/docs/types/test.ts +129 -0
  41. package/open/lib/defaults.json +4 -0
  42. package/open/lib/index.js +63 -0
  43. package/open/lib/main.js +64 -0
  44. package/open/lib/sync.js +68 -0
  45. package/open/package.json +64 -0
  46. package/package.json +67 -4
  47. package/read-dir/README.md +232 -0
  48. package/read-dir/bin/cli +83 -0
  49. package/read-dir/docs/repl.txt +44 -0
  50. package/read-dir/docs/types/index.d.ts +99 -0
  51. package/read-dir/docs/types/test.ts +85 -0
  52. package/read-dir/docs/usage.txt +8 -0
  53. package/read-dir/etc/cli_opts.json +14 -0
  54. package/read-dir/lib/async.js +57 -0
  55. package/read-dir/lib/index.js +62 -0
  56. package/read-dir/lib/sync.js +52 -0
  57. package/read-dir/package.json +69 -0
  58. package/read-file/README.md +246 -0
  59. package/read-file/bin/cli +91 -0
  60. package/read-file/docs/repl.txt +68 -0
  61. package/read-file/docs/types/index.d.ts +138 -0
  62. package/read-file/docs/types/test.ts +147 -0
  63. package/read-file/docs/usage.txt +10 -0
  64. package/read-file/etc/cli_opts.json +21 -0
  65. package/read-file/lib/index.js +61 -0
  66. package/read-file/lib/main.js +59 -0
  67. package/read-file/lib/sync.js +61 -0
  68. package/read-file/package.json +68 -0
  69. package/read-file-list/README.md +197 -0
  70. package/read-file-list/bin/cli +100 -0
  71. package/read-file-list/docs/repl.txt +81 -0
  72. package/read-file-list/docs/types/index.d.ts +166 -0
  73. package/read-file-list/docs/types/test.ts +166 -0
  74. package/read-file-list/docs/usage.txt +10 -0
  75. package/read-file-list/etc/cli_opts.json +21 -0
  76. package/read-file-list/lib/async.js +202 -0
  77. package/read-file-list/lib/clear_pending.js +47 -0
  78. package/read-file-list/lib/clear_timeout.js +23 -0
  79. package/read-file-list/lib/config.json +4 -0
  80. package/read-file-list/lib/delay.js +47 -0
  81. package/read-file-list/lib/index.js +66 -0
  82. package/read-file-list/lib/sync.js +94 -0
  83. package/read-file-list/package.json +72 -0
  84. package/read-json/README.md +176 -0
  85. package/read-json/docs/repl.txt +72 -0
  86. package/read-json/docs/types/index.d.ts +170 -0
  87. package/read-json/docs/types/test.ts +175 -0
  88. package/read-json/lib/async.js +114 -0
  89. package/read-json/lib/index.js +65 -0
  90. package/read-json/lib/sync.js +89 -0
  91. package/read-json/package.json +66 -0
  92. package/read-ndjson/README.md +166 -0
  93. package/read-ndjson/docs/repl.txt +72 -0
  94. package/read-ndjson/docs/types/index.d.ts +170 -0
  95. package/read-ndjson/docs/types/test.ts +179 -0
  96. package/read-ndjson/lib/async.js +114 -0
  97. package/read-ndjson/lib/index.js +65 -0
  98. package/read-ndjson/lib/sync.js +89 -0
  99. package/read-ndjson/package.json +68 -0
  100. package/read-wasm/README.md +158 -0
  101. package/read-wasm/docs/repl.txt +58 -0
  102. package/read-wasm/docs/types/index.d.ts +153 -0
  103. package/read-wasm/docs/types/test.ts +127 -0
  104. package/read-wasm/lib/async.js +106 -0
  105. package/read-wasm/lib/index.js +67 -0
  106. package/read-wasm/lib/sync.js +86 -0
  107. package/read-wasm/package.json +67 -0
  108. package/rename/README.md +259 -0
  109. package/rename/bin/cli +89 -0
  110. package/rename/docs/repl.txt +80 -0
  111. package/rename/docs/types/index.d.ts +109 -0
  112. package/rename/docs/types/test.ts +111 -0
  113. package/rename/docs/usage.txt +7 -0
  114. package/rename/etc/cli_opts.json +15 -0
  115. package/rename/lib/index.js +60 -0
  116. package/rename/lib/main.js +51 -0
  117. package/rename/lib/sync.js +53 -0
  118. package/rename/package.json +73 -0
  119. package/resolve-parent-path/README.md +204 -0
  120. package/resolve-parent-path/bin/cli +85 -0
  121. package/resolve-parent-path/docs/repl.txt +58 -0
  122. package/resolve-parent-path/docs/types/index.d.ts +128 -0
  123. package/resolve-parent-path/docs/types/test.ts +117 -0
  124. package/resolve-parent-path/docs/usage.txt +9 -0
  125. package/resolve-parent-path/etc/cli_opts.json +17 -0
  126. package/resolve-parent-path/lib/async.js +116 -0
  127. package/resolve-parent-path/lib/index.js +58 -0
  128. package/resolve-parent-path/lib/sync.js +83 -0
  129. package/resolve-parent-path/lib/validate.js +67 -0
  130. package/resolve-parent-path/package.json +78 -0
  131. package/resolve-parent-path-by/README.md +220 -0
  132. package/resolve-parent-path-by/docs/repl.txt +105 -0
  133. package/resolve-parent-path-by/docs/types/index.d.ts +220 -0
  134. package/resolve-parent-path-by/docs/types/test.ts +225 -0
  135. package/resolve-parent-path-by/lib/async.js +156 -0
  136. package/resolve-parent-path-by/lib/index.js +67 -0
  137. package/resolve-parent-path-by/lib/sync.js +98 -0
  138. package/resolve-parent-path-by/lib/validate.js +67 -0
  139. package/resolve-parent-path-by/package.json +76 -0
  140. package/resolve-parent-paths/README.md +228 -0
  141. package/resolve-parent-paths/bin/cli +93 -0
  142. package/resolve-parent-paths/docs/repl.txt +84 -0
  143. package/resolve-parent-paths/docs/types/index.d.ts +145 -0
  144. package/resolve-parent-paths/docs/types/test.ts +196 -0
  145. package/resolve-parent-paths/docs/usage.txt +10 -0
  146. package/resolve-parent-paths/etc/cli_opts.json +18 -0
  147. package/resolve-parent-paths/lib/index.js +60 -0
  148. package/resolve-parent-paths/lib/main.js +415 -0
  149. package/resolve-parent-paths/lib/sync.js +231 -0
  150. package/resolve-parent-paths/lib/validate.js +81 -0
  151. package/resolve-parent-paths/package.json +78 -0
  152. package/unlink/README.md +233 -0
  153. package/unlink/bin/cli +81 -0
  154. package/unlink/docs/repl.txt +62 -0
  155. package/unlink/docs/types/index.d.ts +105 -0
  156. package/unlink/docs/types/test.ts +85 -0
  157. package/unlink/docs/usage.txt +7 -0
  158. package/unlink/etc/cli_opts.json +15 -0
  159. package/unlink/lib/index.js +60 -0
  160. package/unlink/lib/main.js +50 -0
  161. package/unlink/lib/sync.js +52 -0
  162. package/unlink/package.json +70 -0
  163. package/write-file/README.md +250 -0
  164. package/write-file/bin/cli +110 -0
  165. package/write-file/docs/repl.txt +74 -0
  166. package/write-file/docs/types/index.d.ts +133 -0
  167. package/write-file/docs/types/test.ts +193 -0
  168. package/write-file/docs/usage.txt +10 -0
  169. package/write-file/etc/cli_opts.json +22 -0
  170. package/write-file/lib/index.js +60 -0
  171. package/write-file/lib/main.js +58 -0
  172. package/write-file/lib/sync.js +58 -0
  173. package/write-file/package.json +68 -0
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @license Apache-2.0
5
+ *
6
+ * Copyright (c) 2018 The Stdlib Authors.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ // MODULES //
24
+
25
+ var resolve = require( 'path' ).resolve;
26
+ var readFileSync = require( '@stdlib/fs/read-file' ).sync;
27
+ var CLI = require( '@stdlib/cli/ctor' );
28
+ var cwd = require( '@stdlib/process/cwd' );
29
+ var readFileList = require( './../lib' );
30
+
31
+
32
+ // MAIN //
33
+
34
+ /**
35
+ * Main execution sequence.
36
+ *
37
+ * @private
38
+ * @returns {void}
39
+ */
40
+ function main() {
41
+ var flags;
42
+ var files;
43
+ var opts;
44
+ var cli;
45
+ var dir;
46
+ var i;
47
+
48
+ // Create a command-line interface:
49
+ cli = new CLI({
50
+ 'pkg': require( './../package.json' ),
51
+ 'options': require( './../etc/cli_opts.json' ),
52
+ 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
53
+ 'encoding': 'utf8'
54
+ })
55
+ });
56
+
57
+ // Get any provided command-line options:
58
+ flags = cli.flags();
59
+ if ( flags.help || flags.version ) {
60
+ return;
61
+ }
62
+
63
+ // Get any provided command-line arguments:
64
+ files = cli.args();
65
+
66
+ opts = {};
67
+ if ( flags.encoding ) {
68
+ opts.encoding = flags.encoding;
69
+ }
70
+ if ( flags.flag ) {
71
+ opts.flag = flags.flag;
72
+ }
73
+
74
+ dir = cwd();
75
+ for ( i = 0; i < files.length; i++ ) {
76
+ files[ i ] = resolve( dir, files[ i ] );
77
+ }
78
+ readFileList( files, opts, onFiles );
79
+
80
+ /**
81
+ * Callback invoked upon reading the contents of one or more files.
82
+ *
83
+ * @private
84
+ * @param {(Error|null)} error - error object
85
+ * @param {ObjectArray} results - results
86
+ * @returns {void}
87
+ */
88
+ function onFiles( error, results ) {
89
+ var i;
90
+ if ( error ) {
91
+ return cli.error( error );
92
+ }
93
+ for ( i = 0; i < results.length; i++ ) {
94
+ results[ i ].data = results[ i ].data.toString();
95
+ console.log( JSON.stringify( results[ i ] ) ); // eslint-disable-line no-console
96
+ }
97
+ }
98
+ }
99
+
100
+ main();
@@ -0,0 +1,81 @@
1
+
2
+ {{alias}}( filepaths[, options], clbk )
3
+ Asynchronously reads the entire contents of each file in a file list.
4
+
5
+ If a provided an encoding, the function returns file contents as strings.
6
+ Otherwise, the function returns Buffer objects.
7
+
8
+ Each file is represented by an object with the following fields:
9
+
10
+ - file: file path.
11
+ - data: file contents as either a Buffer or string.
12
+
13
+ Parameters
14
+ ----------
15
+ filepaths: Array<string>
16
+ Filepaths.
17
+
18
+ options: Object|string (optional)
19
+ Options. If a string, the value is the encoding.
20
+
21
+ options.encoding: string|null (optional)
22
+ Encoding. Default: null.
23
+
24
+ options.flag: string (optional)
25
+ Flag. Default: 'r'.
26
+
27
+ clbk: Function
28
+ Callback to invoke upon reading file contents.
29
+
30
+ Examples
31
+ --------
32
+ > function onRead( error, data ) {
33
+ ... if ( error ) {
34
+ ... console.error( error.message );
35
+ ... } else {
36
+ ... console.log( data );
37
+ ... }
38
+ ... };
39
+ > var filepaths = [ './beep/boop.txt', './foo/bar.txt' ];
40
+ > {{alias}}( filepaths, onRead );
41
+
42
+
43
+ {{alias}}.sync( filepaths[, options] )
44
+ Synchronously reads the entire contents of each file in a file list.
45
+
46
+ If a provided an encoding, the function returns file contents as strings.
47
+ Otherwise, the function returns Buffer objects.
48
+
49
+ Parameters
50
+ ----------
51
+ filepaths: Array<string>
52
+ Filepaths.
53
+
54
+ options: Object|string (optional)
55
+ Options. If a string, the value is the encoding.
56
+
57
+ options.encoding: string|null (optional)
58
+ Encoding. Default: null.
59
+
60
+ options.flag: string (optional)
61
+ Flag. Default: 'r'.
62
+
63
+ Returns
64
+ -------
65
+ out: Error|Array|Array<string>
66
+ File contents.
67
+
68
+ out[ i ].file: string
69
+ File path.
70
+
71
+ out[ i ].data: Buffer|string
72
+ File contents.
73
+
74
+ Examples
75
+ --------
76
+ > var filepaths = [ './beep/boop.txt', './foo/bar.txt' ];
77
+ > var out = {{alias}}.sync( filepaths );
78
+
79
+ See Also
80
+ --------
81
+
@@ -0,0 +1,166 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2020 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
+ // TypeScript Version: 4.1
20
+
21
+ /// <reference types="node"/>
22
+
23
+ import { Buffer } from 'buffer';
24
+
25
+ /**
26
+ * Interface defining function options.
27
+ */
28
+ interface Options {
29
+ /**
30
+ * Encoding (default: null).
31
+ */
32
+ encoding?: string | null;
33
+
34
+ /**
35
+ * Flag (default: 'r').
36
+ */
37
+ flag?: string;
38
+ }
39
+
40
+ /**
41
+ * Interface defining a file.
42
+ */
43
+ interface File {
44
+ /**
45
+ * File path.
46
+ */
47
+ file: string;
48
+
49
+ /**
50
+ * File contents.
51
+ */
52
+ data: Buffer | string;
53
+ }
54
+
55
+ /**
56
+ * Callback invoked upon reading files.
57
+ *
58
+ * @param err - error object
59
+ * @param files - file objects
60
+ */
61
+ type Callback = ( err: Error | null, files: Array<File> ) => void;
62
+
63
+ /**
64
+ * Interface for reading the entire contents of each file in a file list.
65
+ */
66
+ interface ReadFileList {
67
+ /**
68
+ * Asynchronously reads the entire contents of each file in a file list.
69
+ *
70
+ * @param list - list of file paths
71
+ * @param options - options
72
+ * @param options.encoding - file encoding
73
+ * @param options.flag - file status flag
74
+ * @param clbk - callback to invoke after reading file contents
75
+ *
76
+ * @example
77
+ * var list = [ __filename ];
78
+ *
79
+ * readFileList( list, onFiles );
80
+ *
81
+ * function onFiles( error, files ) {
82
+ * if ( error ) {
83
+ * throw error;
84
+ * }
85
+ * console.dir( files );
86
+ * }
87
+ */
88
+ ( list: Array<string>, options: Options | string, clbk: Callback ): void;
89
+
90
+ /**
91
+ * Asynchronously reads the entire contents of each file in a file list.
92
+ *
93
+ * @param list - list of file paths
94
+ * @param clbk - callback to invoke after reading file contents
95
+ *
96
+ * @example
97
+ * var list = [ __filename ];
98
+ *
99
+ * readFileList( list, onFiles );
100
+ *
101
+ * function onFiles( error, files ) {
102
+ * if ( error ) {
103
+ * throw error;
104
+ * }
105
+ * console.dir( files );
106
+ * }
107
+ */
108
+ ( list: Array<string>, clbk: Callback ): void;
109
+
110
+ /**
111
+ * Synchronously reads the entire contents of each file in a file list.
112
+ *
113
+ * @param list - list of file paths
114
+ * @param options - options
115
+ * @param options.encoding - file encoding
116
+ * @param options.flag - file status flag
117
+ * @returns file contents
118
+ *
119
+ * @example
120
+ * var list = [ __filename ];
121
+ * var files = readFileList.sync( list );
122
+ *
123
+ * if ( files instanceof Error ) {
124
+ * throw files;
125
+ * }
126
+ * console.dir( files );
127
+ */
128
+ sync( list: Array<string>, options?: Options | string ): Array<File> | Error;
129
+ }
130
+
131
+ /**
132
+ * Asynchronously reads the entire contents of each file in a file list.
133
+ *
134
+ * @param list - list of file paths
135
+ * @param options - options
136
+ * @param options.encoding - file encoding
137
+ * @param options.flag - file status flag
138
+ * @param clbk - callback to invoke after reading file contents
139
+ *
140
+ * @example
141
+ * var list = [ __filename ];
142
+ *
143
+ * readFileList( list, onFiles );
144
+ *
145
+ * function onFiles( error, files ) {
146
+ * if ( error ) {
147
+ * throw error;
148
+ * }
149
+ * console.dir( files );
150
+ * }
151
+ *
152
+ * @example
153
+ * var list = [ __filename ];
154
+ * var files = readFileList.sync( list );
155
+ *
156
+ * if ( files instanceof Error ) {
157
+ * throw files;
158
+ * }
159
+ * console.dir( files );
160
+ */
161
+ declare var readFileList: ReadFileList;
162
+
163
+
164
+ // EXPORTS //
165
+
166
+ export = readFileList;
@@ -0,0 +1,166 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2020 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 readFileList = require( './index' );
20
+
21
+ /**
22
+ * Interface defining a file.
23
+ */
24
+ interface File {
25
+ /**
26
+ * File path.
27
+ */
28
+ file: string;
29
+
30
+ /**
31
+ * File contents.
32
+ */
33
+ data: Buffer | string;
34
+ }
35
+
36
+ const onLoad = ( error: Error | null, files: Array<File> ) => {
37
+ if ( error || !files ) {
38
+ throw error;
39
+ }
40
+ };
41
+
42
+
43
+ // TESTS //
44
+
45
+ // The function does not have a return value...
46
+ {
47
+ readFileList( [ 'beepboop' ], onLoad ); // $ExpectType void
48
+ }
49
+
50
+ // The compiler throws an error if the function is provided a first argument which is not a string array...
51
+ {
52
+ readFileList( 123, onLoad ); // $ExpectError
53
+ readFileList( 'abc', onLoad ); // $ExpectError
54
+ readFileList( false, onLoad ); // $ExpectError
55
+ readFileList( true, onLoad ); // $ExpectError
56
+ readFileList( null, onLoad ); // $ExpectError
57
+ readFileList( undefined, onLoad ); // $ExpectError
58
+ readFileList( [ 123 ], onLoad ); // $ExpectError
59
+ readFileList( {}, onLoad ); // $ExpectError
60
+ readFileList( ( x: number ): number => x, onLoad ); // $ExpectError
61
+ }
62
+
63
+ // The compiler throws an error if the function is provided a callback argument which is not a function with the expected signature...
64
+ {
65
+ readFileList( [ 'beepboop' ], 'abc' ); // $ExpectError
66
+ readFileList( [ 'beepboop' ], 1 ); // $ExpectError
67
+ readFileList( [ 'beepboop' ], false ); // $ExpectError
68
+ readFileList( [ 'beepboop' ], true ); // $ExpectError
69
+ readFileList( [ 'beepboop' ], null ); // $ExpectError
70
+ readFileList( [ 'beepboop' ], undefined ); // $ExpectError
71
+ readFileList( [ 'beepboop' ], [] ); // $ExpectError
72
+ readFileList( [ 'beepboop' ], {} ); // $ExpectError
73
+ readFileList( [ 'beepboop' ], ( x: number ): number => x ); // $ExpectError
74
+ }
75
+
76
+ // The compiler throws an error if the function is provided an options argument which is not an object or string...
77
+ {
78
+ readFileList( [ 'beepboop' ], false, onLoad ); // $ExpectError
79
+ readFileList( [ 'beepboop' ], true, onLoad ); // $ExpectError
80
+ readFileList( [ 'beepboop' ], null, onLoad ); // $ExpectError
81
+ readFileList( [ 'beepboop' ], undefined, onLoad ); // $ExpectError
82
+ readFileList( [ 'beepboop' ], 123, onLoad ); // $ExpectError
83
+ readFileList( [ 'beepboop' ], [], onLoad ); // $ExpectError
84
+ readFileList( [ 'beepboop' ], ( x: number ): number => x, onLoad ); // $ExpectError
85
+ }
86
+
87
+ // The compiler throws an error if the function is provided an `encoding` option which is not a string or null...
88
+ {
89
+ readFileList( [ 'beepboop' ], { 'encoding': 123 }, onLoad ); // $ExpectError
90
+ readFileList( [ 'beepboop' ], { 'encoding': true }, onLoad ); // $ExpectError
91
+ readFileList( [ 'beepboop' ], { 'encoding': false }, onLoad ); // $ExpectError
92
+ readFileList( [ 'beepboop' ], { 'encoding': [] }, onLoad ); // $ExpectError
93
+ readFileList( [ 'beepboop' ], { 'encoding': {} }, onLoad ); // $ExpectError
94
+ readFileList( [ 'beepboop' ], { 'encoding': ( x: number ): number => x }, onLoad ); // $ExpectError
95
+ }
96
+
97
+ // The compiler throws an error if the function is provided a `flag` option which is not a string...
98
+ {
99
+ readFileList( [ 'beepboop' ], { 'flag': 123 }, onLoad ); // $ExpectError
100
+ readFileList( [ 'beepboop' ], { 'flag': true }, onLoad ); // $ExpectError
101
+ readFileList( [ 'beepboop' ], { 'flag': false }, onLoad ); // $ExpectError
102
+ readFileList( [ 'beepboop' ], { 'flag': null }, onLoad ); // $ExpectError
103
+ readFileList( [ 'beepboop' ], { 'flag': [] }, onLoad ); // $ExpectError
104
+ readFileList( [ 'beepboop' ], { 'flag': {} }, onLoad ); // $ExpectError
105
+ readFileList( [ 'beepboop' ], { 'flag': ( x: number ): number => x }, onLoad ); // $ExpectError
106
+ }
107
+
108
+ // The compiler throws an error if the function is provided an unsupported number of arguments...
109
+ {
110
+ readFileList(); // $ExpectError
111
+ readFileList( [ 'C:\\foo\\bar\\baz\\package.json' ] ); // $ExpectError
112
+ }
113
+
114
+ // Attached to main export is a `sync` method which returns a string or an error...
115
+ {
116
+ readFileList.sync( [ 'beepboop' ] ); // $ExpectType Error | File[]
117
+ }
118
+
119
+ // The compiler throws an error if the `sync` method is provided a first argument which is not a string array...
120
+ {
121
+ readFileList.sync( 123 ); // $ExpectError
122
+ readFileList.sync( 'abc' ); // $ExpectError
123
+ readFileList.sync( false ); // $ExpectError
124
+ readFileList.sync( true ); // $ExpectError
125
+ readFileList.sync( null ); // $ExpectError
126
+ readFileList.sync( undefined ); // $ExpectError
127
+ readFileList.sync( [ 123 ] ); // $ExpectError
128
+ readFileList.sync( {} ); // $ExpectError
129
+ readFileList.sync( ( x: number ): number => x ); // $ExpectError
130
+ }
131
+
132
+ // The compiler throws an error if the `sync` method is provided an options argument which is not an object or string...
133
+ {
134
+ readFileList.sync( [ 'beepboop' ], null ); // $ExpectError
135
+ readFileList.sync( [ 'beepboop' ], true ); // $ExpectError
136
+ readFileList.sync( [ 'beepboop' ], false ); // $ExpectError
137
+ readFileList.sync( [ 'beepboop' ], 123 ); // $ExpectError
138
+ readFileList.sync( [ 'beepboop' ], [] ); // $ExpectError
139
+ readFileList.sync( [ 'beepboop' ], ( x: number ): number => x ); // $ExpectError
140
+ }
141
+
142
+ // The compiler throws an error if the `sync` method is provided an `encoding` option which is not a string or null...
143
+ {
144
+ readFileList.sync( [ 'beepboop' ], { 'encoding': 123 } ); // $ExpectError
145
+ readFileList.sync( [ 'beepboop' ], { 'encoding': true } ); // $ExpectError
146
+ readFileList.sync( [ 'beepboop' ], { 'encoding': false } ); // $ExpectError
147
+ readFileList.sync( [ 'beepboop' ], { 'encoding': [] } ); // $ExpectError
148
+ readFileList.sync( [ 'beepboop' ], { 'encoding': {} } ); // $ExpectError
149
+ readFileList.sync( [ 'beepboop' ], { 'encoding': ( x: number ): number => x } ); // $ExpectError
150
+ }
151
+
152
+ // The compiler throws an error if the `sync` method is provided a `flag` option which is not a string...
153
+ {
154
+ readFileList.sync( [ 'beepboop' ], { 'flag': 123 } ); // $ExpectError
155
+ readFileList.sync( [ 'beepboop' ], { 'flag': true } ); // $ExpectError
156
+ readFileList.sync( [ 'beepboop' ], { 'flag': false } ); // $ExpectError
157
+ readFileList.sync( [ 'beepboop' ], { 'flag': null } ); // $ExpectError
158
+ readFileList.sync( [ 'beepboop' ], { 'flag': [] } ); // $ExpectError
159
+ readFileList.sync( [ 'beepboop' ], { 'flag': {} } ); // $ExpectError
160
+ readFileList.sync( [ 'beepboop' ], { 'flag': ( x: number ): number => x } ); // $ExpectError
161
+ }
162
+
163
+ // The compiler throws an error if the `sync` method is provided an unsupported number of arguments...
164
+ {
165
+ readFileList.sync(); // $ExpectError
166
+ }
@@ -0,0 +1,10 @@
1
+
2
+ Usage: read-file-list [options] <filepath1> <filepath2> ...
3
+
4
+ Options:
5
+
6
+ -h, --help Print this message.
7
+ -V, --version Print the package version.
8
+ --enc, --encoding encoding Encoding.
9
+ --flag flag Flag. Default: 'r'.
10
+
@@ -0,0 +1,21 @@
1
+ {
2
+ "string": [
3
+ "encoding",
4
+ "flag"
5
+ ],
6
+ "boolean": [
7
+ "help",
8
+ "version"
9
+ ],
10
+ "alias": {
11
+ "help": [
12
+ "h"
13
+ ],
14
+ "version": [
15
+ "V"
16
+ ],
17
+ "encoding": [
18
+ "enc"
19
+ ]
20
+ }
21
+ }