Skip to content

Commit 7c123b1

Browse files
committed
Rename join and update docs for rendering
1 parent 8c94e8d commit 7c123b1

File tree

2 files changed

+100
-53
lines changed

2 files changed

+100
-53
lines changed

README.md

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,98 @@
22

33
## Module Node.Path
44

5-
### Types
5+
#### `FilePath`
66

7-
type FilePath = String
7+
``` purescript
8+
type FilePath = String
9+
```
810

11+
Type for strings representing file paths.
912

10-
### Values
13+
#### `normalize`
1114

12-
basename :: FilePath -> FilePath
15+
``` purescript
16+
normalize :: FilePath -> FilePath
17+
```
1318

14-
basenameWithoutExt :: FilePath -> FilePath -> FilePath
19+
Normalize a string path, taking care of `..` and `.`, duplicated slashes,
20+
etc. If the path contains a trailing slash it is preserved. On Windows
21+
backslashes are used.
1522

16-
delimiter :: String
23+
#### `concat`
1724

18-
dirname :: FilePath -> FilePath
25+
``` purescript
26+
concat :: [FilePath] -> FilePath
27+
```
1928

20-
extname :: FilePath -> FilePath
29+
Concatenates multiple path segments together and normalizes the resulting path.
2130

22-
join :: [FilePath] -> FilePath
31+
#### `resolve`
2332

24-
normalize :: FilePath -> FilePath
33+
``` purescript
34+
resolve :: [FilePath] -> FilePath -> FilePath
35+
```
36+
37+
Resolves `to` to an absolute path ([from...], to).
38+
39+
#### `relative`
40+
41+
``` purescript
42+
relative :: FilePath -> FilePath -> FilePath
43+
```
44+
45+
Solve the relative path from `from` to `to`.
46+
47+
#### `dirname`
48+
49+
``` purescript
50+
dirname :: FilePath -> FilePath
51+
```
52+
53+
Return the directory name of a path.
54+
55+
#### `basename`
56+
57+
``` purescript
58+
basename :: FilePath -> FilePath
59+
```
60+
61+
Return the last portion of a path.
62+
63+
#### `basenameWithoutExt`
64+
65+
``` purescript
66+
basenameWithoutExt :: FilePath -> FilePath -> FilePath
67+
```
68+
69+
Return the last portion of a path, also dropping a specific file extension
70+
if it matches the end of the name.
71+
72+
#### `extname`
73+
74+
``` purescript
75+
extname :: FilePath -> FilePath
76+
```
77+
78+
Return the extension of the path, from the last `.` to end of string in the
79+
last portion of the path. If there is no `.` in the last portion of the
80+
path or the first character of it is `.`, then it returns an empty string.
81+
82+
#### `sep`
83+
84+
``` purescript
85+
sep :: String
86+
```
87+
88+
The platform-specific file separator. `\\` or `/`.
89+
90+
#### `delimiter`
91+
92+
``` purescript
93+
delimiter :: String
94+
```
95+
96+
The platform-specific path delimiter, `;` or `:`.
2597

26-
relative :: FilePath -> FilePath -> FilePath
2798

28-
resolve :: [FilePath] -> FilePath -> FilePath
2999

30-
sep :: String

src/Node/Path.purs

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,66 @@
11
module Node.Path where
22

3-
-- |
4-
-- Type for strings representing file paths.
5-
--
3+
-- | Type for strings representing file paths.
64
type FilePath = String
75

8-
-- |
9-
-- Normalize a string path, taking care of `..` and `.`, duplicated slashes,
10-
-- etc. If the path contains a trailing slash it is preserved. On Windows
11-
-- backslashes are used.
12-
--
6+
-- | Normalize a string path, taking care of `..` and `.`, duplicated slashes,
7+
-- | etc. If the path contains a trailing slash it is preserved. On Windows
8+
-- | backslashes are used.
139
foreign import normalize
1410
"var normalize = require('path').normalize;" :: FilePath -> FilePath
1511

16-
-- |
17-
-- Joins two path segments together and normalizes the resulting path.
18-
--
19-
foreign import join
20-
"var join = function (segments) { \
12+
-- | Concatenates multiple path segments together and normalizes the resulting path.
13+
foreign import concat
14+
"var concat = function (segments) { \
2115
\ return require('path').join.apply(this, segments); \
2216
\}" :: [FilePath] -> FilePath
2317

24-
-- |
25-
-- Resolves `to` to an absolute path ([from...], to).
26-
--
18+
-- | Resolves `to` to an absolute path ([from...], to).
2719
foreign import resolve
2820
"var resolve = function (from) { \
2921
\ return function (to) { \
3022
\ return require('path').resolve.apply(this, from.concat([to])); \
3123
\ }; \
3224
\};" :: [FilePath] -> FilePath -> FilePath
3325

34-
-- |
35-
-- Solve the relative path from `from` to `to`.
36-
--
26+
-- | Solve the relative path from `from` to `to`.
3727
foreign import relative
3828
"var relative = function (from) { \
3929
\ return function (to) { \
4030
\ return require('path').relative(from, to); \
4131
\ }; \
4232
\}" :: FilePath -> FilePath -> FilePath
4333

44-
-- |
45-
-- Return the directory name of a path.
46-
--
34+
-- | Return the directory name of a path.
4735
foreign import dirname
4836
"var dirname = function (path) { \
4937
\ var p = require('path'); \
5038
\ return p.normalize(p.dirname(path)); \
5139
\}" :: FilePath -> FilePath
5240

53-
-- |
54-
-- Return the last portion of a path.
55-
--
41+
-- | Return the last portion of a path.
5642
foreign import basename
5743
"var basename = require('path').basename;" :: FilePath -> FilePath
5844

59-
-- |
60-
-- Return the last portion of a path, also dropping a specific file extension
61-
-- if it matches the end of the name.
62-
--
45+
-- | Return the last portion of a path, also dropping a specific file extension
46+
-- | if it matches the end of the name.
6347
foreign import basenameWithoutExt
6448
"var basenameWithoutExt = function (path) { \
6549
\ return function (ext) { \
6650
\ return require('path').basename(path, ext); \
6751
\ }; \
6852
\}" :: FilePath -> FilePath -> FilePath
6953

70-
-- |
71-
-- Return the extension of the path, from the last `.` to end of string in the
72-
-- last portion of the path. If there is no `.` in the last portion of the path
73-
-- or the first character of it is `.`, then it returns an empty string.
74-
--
54+
-- | Return the extension of the path, from the last `.` to end of string in the
55+
-- | last portion of the path. If there is no `.` in the last portion of the
56+
-- | path or the first character of it is `.`, then it returns an empty string.
7557
foreign import extname
7658
"var extname = require('path').extname;" :: FilePath -> FilePath
7759

78-
-- |
79-
-- The platform-specific file separator. `\\` or `/`.
80-
--
60+
-- | The platform-specific file separator. `\\` or `/`.
8161
foreign import sep
8262
"var sep = require('path').sep;" :: String
8363

84-
-- |
85-
-- The platform-specific path delimiter, `;` or `:`.
86-
--
64+
-- | The platform-specific path delimiter, `;` or `:`.
8765
foreign import delimiter
8866
"var delimiter = require('path').delimiter;" :: String

0 commit comments

Comments
 (0)