@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.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +230 -2
- package/SECURITY.md +5 -0
- package/append-file/README.md +239 -0
- package/append-file/bin/cli +110 -0
- package/append-file/docs/repl.txt +72 -0
- package/append-file/docs/types/index.d.ts +133 -0
- package/append-file/docs/types/test.ts +193 -0
- package/append-file/docs/usage.txt +10 -0
- package/append-file/etc/cli_opts.json +22 -0
- package/append-file/lib/async.js +58 -0
- package/append-file/lib/index.js +61 -0
- package/append-file/lib/sync.js +58 -0
- package/append-file/package.json +69 -0
- package/close/README.md +172 -0
- package/close/docs/repl.txt +45 -0
- package/close/docs/types/index.d.ts +135 -0
- package/close/docs/types/test.ts +89 -0
- package/close/lib/index.js +73 -0
- package/close/lib/main.js +68 -0
- package/close/lib/sync.js +65 -0
- package/close/package.json +64 -0
- package/docs/types/index.d.ts +502 -0
- package/exists/README.md +252 -0
- package/exists/bin/cli +83 -0
- package/exists/docs/repl.txt +42 -0
- package/exists/docs/types/index.d.ts +112 -0
- package/exists/docs/types/test.ts +87 -0
- package/exists/docs/usage.txt +8 -0
- package/exists/etc/cli_opts.json +14 -0
- package/exists/lib/async.js +85 -0
- package/exists/lib/index.js +66 -0
- package/exists/lib/sync.js +62 -0
- package/exists/package.json +69 -0
- package/lib/index.js +186 -0
- package/open/README.md +204 -0
- package/open/docs/repl.txt +65 -0
- package/open/docs/types/index.d.ts +150 -0
- package/open/docs/types/test.ts +129 -0
- package/open/lib/defaults.json +4 -0
- package/open/lib/index.js +63 -0
- package/open/lib/main.js +64 -0
- package/open/lib/sync.js +68 -0
- package/open/package.json +64 -0
- package/package.json +67 -4
- package/read-dir/README.md +232 -0
- package/read-dir/bin/cli +83 -0
- package/read-dir/docs/repl.txt +44 -0
- package/read-dir/docs/types/index.d.ts +99 -0
- package/read-dir/docs/types/test.ts +85 -0
- package/read-dir/docs/usage.txt +8 -0
- package/read-dir/etc/cli_opts.json +14 -0
- package/read-dir/lib/async.js +57 -0
- package/read-dir/lib/index.js +62 -0
- package/read-dir/lib/sync.js +52 -0
- package/read-dir/package.json +69 -0
- package/read-file/README.md +246 -0
- package/read-file/bin/cli +91 -0
- package/read-file/docs/repl.txt +68 -0
- package/read-file/docs/types/index.d.ts +138 -0
- package/read-file/docs/types/test.ts +147 -0
- package/read-file/docs/usage.txt +10 -0
- package/read-file/etc/cli_opts.json +21 -0
- package/read-file/lib/index.js +61 -0
- package/read-file/lib/main.js +59 -0
- package/read-file/lib/sync.js +61 -0
- package/read-file/package.json +68 -0
- package/read-file-list/README.md +197 -0
- package/read-file-list/bin/cli +100 -0
- package/read-file-list/docs/repl.txt +81 -0
- package/read-file-list/docs/types/index.d.ts +166 -0
- package/read-file-list/docs/types/test.ts +166 -0
- package/read-file-list/docs/usage.txt +10 -0
- package/read-file-list/etc/cli_opts.json +21 -0
- package/read-file-list/lib/async.js +202 -0
- package/read-file-list/lib/clear_pending.js +47 -0
- package/read-file-list/lib/clear_timeout.js +23 -0
- package/read-file-list/lib/config.json +4 -0
- package/read-file-list/lib/delay.js +47 -0
- package/read-file-list/lib/index.js +66 -0
- package/read-file-list/lib/sync.js +94 -0
- package/read-file-list/package.json +72 -0
- package/read-json/README.md +176 -0
- package/read-json/docs/repl.txt +72 -0
- package/read-json/docs/types/index.d.ts +170 -0
- package/read-json/docs/types/test.ts +175 -0
- package/read-json/lib/async.js +114 -0
- package/read-json/lib/index.js +65 -0
- package/read-json/lib/sync.js +89 -0
- package/read-json/package.json +66 -0
- package/read-ndjson/README.md +166 -0
- package/read-ndjson/docs/repl.txt +72 -0
- package/read-ndjson/docs/types/index.d.ts +170 -0
- package/read-ndjson/docs/types/test.ts +179 -0
- package/read-ndjson/lib/async.js +114 -0
- package/read-ndjson/lib/index.js +65 -0
- package/read-ndjson/lib/sync.js +89 -0
- package/read-ndjson/package.json +68 -0
- package/read-wasm/README.md +158 -0
- package/read-wasm/docs/repl.txt +58 -0
- package/read-wasm/docs/types/index.d.ts +153 -0
- package/read-wasm/docs/types/test.ts +127 -0
- package/read-wasm/lib/async.js +106 -0
- package/read-wasm/lib/index.js +67 -0
- package/read-wasm/lib/sync.js +86 -0
- package/read-wasm/package.json +67 -0
- package/rename/README.md +259 -0
- package/rename/bin/cli +89 -0
- package/rename/docs/repl.txt +80 -0
- package/rename/docs/types/index.d.ts +109 -0
- package/rename/docs/types/test.ts +111 -0
- package/rename/docs/usage.txt +7 -0
- package/rename/etc/cli_opts.json +15 -0
- package/rename/lib/index.js +60 -0
- package/rename/lib/main.js +51 -0
- package/rename/lib/sync.js +53 -0
- package/rename/package.json +73 -0
- package/resolve-parent-path/README.md +204 -0
- package/resolve-parent-path/bin/cli +85 -0
- package/resolve-parent-path/docs/repl.txt +58 -0
- package/resolve-parent-path/docs/types/index.d.ts +128 -0
- package/resolve-parent-path/docs/types/test.ts +117 -0
- package/resolve-parent-path/docs/usage.txt +9 -0
- package/resolve-parent-path/etc/cli_opts.json +17 -0
- package/resolve-parent-path/lib/async.js +116 -0
- package/resolve-parent-path/lib/index.js +58 -0
- package/resolve-parent-path/lib/sync.js +83 -0
- package/resolve-parent-path/lib/validate.js +67 -0
- package/resolve-parent-path/package.json +78 -0
- package/resolve-parent-path-by/README.md +220 -0
- package/resolve-parent-path-by/docs/repl.txt +105 -0
- package/resolve-parent-path-by/docs/types/index.d.ts +220 -0
- package/resolve-parent-path-by/docs/types/test.ts +225 -0
- package/resolve-parent-path-by/lib/async.js +156 -0
- package/resolve-parent-path-by/lib/index.js +67 -0
- package/resolve-parent-path-by/lib/sync.js +98 -0
- package/resolve-parent-path-by/lib/validate.js +67 -0
- package/resolve-parent-path-by/package.json +76 -0
- package/resolve-parent-paths/README.md +228 -0
- package/resolve-parent-paths/bin/cli +93 -0
- package/resolve-parent-paths/docs/repl.txt +84 -0
- package/resolve-parent-paths/docs/types/index.d.ts +145 -0
- package/resolve-parent-paths/docs/types/test.ts +196 -0
- package/resolve-parent-paths/docs/usage.txt +10 -0
- package/resolve-parent-paths/etc/cli_opts.json +18 -0
- package/resolve-parent-paths/lib/index.js +60 -0
- package/resolve-parent-paths/lib/main.js +415 -0
- package/resolve-parent-paths/lib/sync.js +231 -0
- package/resolve-parent-paths/lib/validate.js +81 -0
- package/resolve-parent-paths/package.json +78 -0
- package/unlink/README.md +233 -0
- package/unlink/bin/cli +81 -0
- package/unlink/docs/repl.txt +62 -0
- package/unlink/docs/types/index.d.ts +105 -0
- package/unlink/docs/types/test.ts +85 -0
- package/unlink/docs/usage.txt +7 -0
- package/unlink/etc/cli_opts.json +15 -0
- package/unlink/lib/index.js +60 -0
- package/unlink/lib/main.js +50 -0
- package/unlink/lib/sync.js +52 -0
- package/unlink/package.json +70 -0
- package/write-file/README.md +250 -0
- package/write-file/bin/cli +110 -0
- package/write-file/docs/repl.txt +74 -0
- package/write-file/docs/types/index.d.ts +133 -0
- package/write-file/docs/types/test.ts +193 -0
- package/write-file/docs/usage.txt +10 -0
- package/write-file/etc/cli_opts.json +22 -0
- package/write-file/lib/index.js +60 -0
- package/write-file/lib/main.js +58 -0
- package/write-file/lib/sync.js +58 -0
- package/write-file/package.json +68 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
{{alias}}( path, clbk )
|
|
3
|
+
Asynchronously removes a directory entry.
|
|
4
|
+
|
|
5
|
+
If a provided path is a symbolic link, the function removes the symbolic
|
|
6
|
+
link named by the path and does not affect any file or directory named by
|
|
7
|
+
the contents of the symbolic link.
|
|
8
|
+
|
|
9
|
+
Otherwise, the function removes the link named by the provided path and
|
|
10
|
+
decrements the link count of the file referenced by the link.
|
|
11
|
+
|
|
12
|
+
When a file's link count becomes 0 and no process has the file open, the
|
|
13
|
+
space occupied by the file is freed and the file is no longer accessible.
|
|
14
|
+
|
|
15
|
+
If one or more processes have the file open when the last link is removed,
|
|
16
|
+
the link is removed before the function returns; however, the removal of
|
|
17
|
+
file contents is postponed until all references to the file are closed.
|
|
18
|
+
|
|
19
|
+
If the path refers to a socket, FIFO, or device, processes which have the
|
|
20
|
+
object open may continue to use it.
|
|
21
|
+
|
|
22
|
+
The path argument should *not* be a directory. To remove a directory, use
|
|
23
|
+
rmdir().
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
path: string|Buffer|integer
|
|
28
|
+
Entry path.
|
|
29
|
+
|
|
30
|
+
clbk: Function
|
|
31
|
+
Callback to invoke upon removing an entry.
|
|
32
|
+
|
|
33
|
+
Examples
|
|
34
|
+
--------
|
|
35
|
+
> function done( error ) {
|
|
36
|
+
... if ( error ) {
|
|
37
|
+
... console.error( error.message );
|
|
38
|
+
... }
|
|
39
|
+
... };
|
|
40
|
+
> {{alias}}( './beep/boop.txt', done );
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
{{alias}}.sync( path )
|
|
44
|
+
Synchronously removes a directory entry.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
path: string|Buffer|integer
|
|
49
|
+
Entry path.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
out: Error|null
|
|
54
|
+
Error object or null.
|
|
55
|
+
|
|
56
|
+
Examples
|
|
57
|
+
--------
|
|
58
|
+
> var out = {{alias}}.sync( './beep/boop.txt' );
|
|
59
|
+
|
|
60
|
+
See Also
|
|
61
|
+
--------
|
|
62
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
* Callback invoked upon removing an entry.
|
|
27
|
+
*/
|
|
28
|
+
type Nullary = () => void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Callback invoked upon removing an entry.
|
|
32
|
+
*
|
|
33
|
+
* @param err - error argument
|
|
34
|
+
*/
|
|
35
|
+
type Unary = ( err: Error | null ) => void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Callback invoked upon removing an entry.
|
|
39
|
+
*
|
|
40
|
+
* @param err - error argument
|
|
41
|
+
*/
|
|
42
|
+
type Callback = Nullary | Unary;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Interface for removing a directory entry.
|
|
46
|
+
*/
|
|
47
|
+
interface Unlink {
|
|
48
|
+
/**
|
|
49
|
+
* Asynchronously removes a directory entry.
|
|
50
|
+
*
|
|
51
|
+
* @param path - entry path
|
|
52
|
+
* @param clbk - callback to invoke after removing a directory entry
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* function done( error ) {
|
|
56
|
+
* if ( error ) {
|
|
57
|
+
* throw error;
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* unlink( './beep/boop.txt', done );
|
|
62
|
+
*/
|
|
63
|
+
( path: string | Buffer | number, clbk: Callback ): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Synchronously removes a directory entry.
|
|
67
|
+
*
|
|
68
|
+
* @param path - path
|
|
69
|
+
* @returns error object or null
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* var err = unlink.sync( './beep/boop.txt' );
|
|
73
|
+
* if ( err instanceof Error ) {
|
|
74
|
+
* throw err;
|
|
75
|
+
* }
|
|
76
|
+
*/
|
|
77
|
+
sync( path: string | Buffer | number ): Error | null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Asynchronously removes a directory entry.
|
|
82
|
+
*
|
|
83
|
+
* @param path - entry path
|
|
84
|
+
* @param clbk - callback to invoke after removing a directory entry
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* function done( error ) {
|
|
88
|
+
* if ( error ) {
|
|
89
|
+
* throw error;
|
|
90
|
+
* }
|
|
91
|
+
* }
|
|
92
|
+
* unlink( './beep/boop.txt', done );
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* var err = unlink.sync( './beep/boop.txt' );
|
|
96
|
+
* if ( err instanceof Error ) {
|
|
97
|
+
* throw err;
|
|
98
|
+
* }
|
|
99
|
+
*/
|
|
100
|
+
declare var unlink: Unlink;
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
// EXPORTS //
|
|
104
|
+
|
|
105
|
+
export = unlink;
|
|
@@ -0,0 +1,85 @@
|
|
|
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 unlink = require( './index' );
|
|
20
|
+
|
|
21
|
+
const done = ( error: Error | null ) => {
|
|
22
|
+
if ( error ) {
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// TESTS //
|
|
29
|
+
|
|
30
|
+
// The function does not have a return value...
|
|
31
|
+
{
|
|
32
|
+
unlink( './beep/boop.txt', done ); // $ExpectType void
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The compiler throws an error if the function is provided a first argument of an unsupported type...
|
|
36
|
+
{
|
|
37
|
+
unlink( false, done ); // $ExpectError
|
|
38
|
+
unlink( true, done ); // $ExpectError
|
|
39
|
+
unlink( null, done ); // $ExpectError
|
|
40
|
+
unlink( undefined, done ); // $ExpectError
|
|
41
|
+
unlink( [], done ); // $ExpectError
|
|
42
|
+
unlink( {}, done ); // $ExpectError
|
|
43
|
+
unlink( ( x: number ): number => x, done ); // $ExpectError
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The compiler throws an error if the function is provided a second argument which is not a function with the expected signature...
|
|
47
|
+
{
|
|
48
|
+
unlink( './beep/boop.txt', 1 ); // $ExpectError
|
|
49
|
+
unlink( './beep/boop.txt', 'abc' ); // $ExpectError
|
|
50
|
+
unlink( './beep/boop.txt', false ); // $ExpectError
|
|
51
|
+
unlink( './beep/boop.txt', true ); // $ExpectError
|
|
52
|
+
unlink( './beep/boop.txt', null ); // $ExpectError
|
|
53
|
+
unlink( './beep/boop.txt', undefined ); // $ExpectError
|
|
54
|
+
unlink( './beep/boop.txt', [] ); // $ExpectError
|
|
55
|
+
unlink( './beep/boop.txt', {} ); // $ExpectError
|
|
56
|
+
unlink( './beep/boop.txt', ( x: number ): number => x ); // $ExpectError
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
60
|
+
{
|
|
61
|
+
unlink(); // $ExpectError
|
|
62
|
+
unlink( 'C:\\foo\\bar\\baz' ); // $ExpectError
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Attached to main export is a `sync` method which returns an error or null...
|
|
66
|
+
{
|
|
67
|
+
unlink.sync( './beep/boop.txt' ); // $ExpectType Error | null
|
|
68
|
+
unlink.sync( 123 ); // $ExpectType Error | null
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// The compiler throws an error if the `sync` method is provided a first argument of an unsupported type...
|
|
72
|
+
{
|
|
73
|
+
unlink.sync( false ); // $ExpectError
|
|
74
|
+
unlink.sync( true ); // $ExpectError
|
|
75
|
+
unlink.sync( null ); // $ExpectError
|
|
76
|
+
unlink.sync( undefined ); // $ExpectError
|
|
77
|
+
unlink.sync( [] ); // $ExpectError
|
|
78
|
+
unlink.sync( {} ); // $ExpectError
|
|
79
|
+
unlink.sync( ( x: number ): number => x ); // $ExpectError
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// The compiler throws an error if the `sync` method is provided an unsupported number of arguments...
|
|
83
|
+
{
|
|
84
|
+
unlink.sync(); // $ExpectError
|
|
85
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Remove a directory entry.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/fs/unlink
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var unlink = require( '@stdlib/fs/unlink' );
|
|
28
|
+
*
|
|
29
|
+
* function done( error ) {
|
|
30
|
+
* if ( error ) {
|
|
31
|
+
* throw error;
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* unlink( './beep/boop.txt', done );
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var unlinkSync = require( '@stdlib/fs/unlink' ).sync;
|
|
39
|
+
*
|
|
40
|
+
* var err = unlinkSync( './beep/boop.txt' );
|
|
41
|
+
* if ( err instanceof Error ) {
|
|
42
|
+
* throw err;
|
|
43
|
+
* }
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
// MODULES //
|
|
47
|
+
|
|
48
|
+
var setReadOnly = require( '@ohos-ports/stdlib-utils/define-nonenumerable-read-only-property' );
|
|
49
|
+
var main = require( './main.js' );
|
|
50
|
+
var sync = require( './sync.js' );
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// MAIN //
|
|
54
|
+
|
|
55
|
+
setReadOnly( main, 'sync', sync );
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// EXPORTS //
|
|
59
|
+
|
|
60
|
+
module.exports = main;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var remove = require( 'fs' ).unlink;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Asynchronously removes a directory entry.
|
|
30
|
+
*
|
|
31
|
+
* @param {(string|Buffer|integer)} path - entry path
|
|
32
|
+
* @param {Function} clbk - callback to invoke after removing a directory entry
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* function done( error ) {
|
|
36
|
+
* if ( error ) {
|
|
37
|
+
* throw error;
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* unlink( './beep/boop.txt', done );
|
|
42
|
+
*/
|
|
43
|
+
function unlink( path, clbk ) {
|
|
44
|
+
remove( path, clbk );
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// EXPORTS //
|
|
49
|
+
|
|
50
|
+
module.exports = unlink;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var unlink = require( 'fs' ).unlinkSync;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Synchronously removes a directory entry.
|
|
30
|
+
*
|
|
31
|
+
* @param {(string|Buffer|integer)} path - path
|
|
32
|
+
* @returns {(Error|null)} error object or null
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* var err = unlinkSync( './beep/boop.txt' );
|
|
36
|
+
* if ( err instanceof Error ) {
|
|
37
|
+
* throw err;
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
function unlinkSync( path ) {
|
|
41
|
+
try {
|
|
42
|
+
unlink( path );
|
|
43
|
+
} catch ( err ) {
|
|
44
|
+
return err;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// EXPORTS //
|
|
51
|
+
|
|
52
|
+
module.exports = unlinkSync;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/fs/unlink",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Remove a directory entry.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "The Stdlib Authors",
|
|
8
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
9
|
+
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "The Stdlib Authors",
|
|
13
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"bin": {
|
|
17
|
+
"unlink": "./bin/cli"
|
|
18
|
+
},
|
|
19
|
+
"main": "./lib",
|
|
20
|
+
"directories": {
|
|
21
|
+
"benchmark": "./benchmark",
|
|
22
|
+
"doc": "./docs",
|
|
23
|
+
"example": "./examples",
|
|
24
|
+
"lib": "./lib",
|
|
25
|
+
"test": "./test"
|
|
26
|
+
},
|
|
27
|
+
"types": "./docs/types",
|
|
28
|
+
"scripts": {},
|
|
29
|
+
"homepage": "https://github.com/stdlib-js/stdlib",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git://github.com/stdlib-js/stdlib.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {},
|
|
38
|
+
"devDependencies": {},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=0.10.0",
|
|
41
|
+
"npm": ">2.7.0"
|
|
42
|
+
},
|
|
43
|
+
"os": [
|
|
44
|
+
"aix",
|
|
45
|
+
"darwin",
|
|
46
|
+
"freebsd",
|
|
47
|
+
"linux",
|
|
48
|
+
"macos",
|
|
49
|
+
"openbsd",
|
|
50
|
+
"sunos",
|
|
51
|
+
"win32",
|
|
52
|
+
"windows"
|
|
53
|
+
],
|
|
54
|
+
"keywords": [
|
|
55
|
+
"stdlib",
|
|
56
|
+
"stdfs",
|
|
57
|
+
"fs",
|
|
58
|
+
"unlink",
|
|
59
|
+
"unlinksync",
|
|
60
|
+
"path",
|
|
61
|
+
"async",
|
|
62
|
+
"sync",
|
|
63
|
+
"file",
|
|
64
|
+
"delete",
|
|
65
|
+
"remove",
|
|
66
|
+
"rm",
|
|
67
|
+
"del",
|
|
68
|
+
"filesystem"
|
|
69
|
+
]
|
|
70
|
+
}
|