Skip to content

Commit 93fa9ce

Browse files
committed
Add documentation for Node.FS.Perms
1 parent 452a9f9 commit 93fa9ce

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,53 @@ exists :: forall eff. FilePath -> (Boolean -> Eff eff Unit) -> Eff (fs :: FS | e
187187
newtype Perm
188188
```
189189

190+
A `Perm` value specifies what is allowed to be done with a particular
191+
file by a particular class of user — that is, whether it is
192+
readable, writable, and/or executable. It has a semigroup instance, which
193+
allows you to combine permissions; for example, `r <> w` means "readable
194+
and writable".
190195

191196
#### `Perms`
192197

193198
``` purescript
194199
newtype Perms
195200
```
196201

202+
A `Perms` value includes all the permissions information about a
203+
particular file or directory,
204+
205+
#### `none`
206+
207+
``` purescript
208+
none :: Perm
209+
```
210+
211+
No permissions. This is the identity of the Semigroup (<>) operation for
212+
Perm.
213+
214+
#### `r`
215+
216+
``` purescript
217+
r :: Perm
218+
```
219+
220+
The "readable" permission.
221+
222+
#### `w`
223+
224+
``` purescript
225+
w :: Perm
226+
```
227+
228+
The "writable" permission.
229+
230+
#### `x`
231+
232+
``` purescript
233+
x :: Perm
234+
```
235+
236+
The "executable" permission.
197237

198238
#### `semigroupPerm`
199239

@@ -215,6 +255,8 @@ permsFromString :: String -> Maybe Perms
215255
mkPerms :: Perm -> Perm -> Perm -> Perms
216256
```
217257

258+
Create a `Perms` value. The arguments represent the user's, group's, and
259+
others' permission sets, respectively.
218260

219261
#### `permsToString`
220262

src/Node/FS/Perms.purs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,38 @@ import Data.Char (Char(), charString)
1717
import Data.String (toCharArray)
1818
import Data.Int (Int(), fromNumber, toNumber)
1919

20+
-- | A `Perm` value specifies what is allowed to be done with a particular
21+
-- | file by a particular class of user &mdash; that is, whether it is
22+
-- | readable, writable, and/or executable. It has a semigroup instance, which
23+
-- | allows you to combine permissions; for example, `r <> w` means "readable
24+
-- | and writable".
2025
newtype Perm = Perm { r :: Boolean, w :: Boolean, x :: Boolean }
26+
27+
-- | A `Perms` value includes all the permissions information about a
28+
-- | particular file or directory,
2129
newtype Perms = Perms { u :: Perm, g :: Perm, o :: Perm }
2230

31+
-- | No permissions. This is the identity of the Semigroup (<>) operation for
32+
-- | Perm.
33+
none :: Perm
2334
none = Perm { r: false, w: false, x: false }
35+
36+
-- | The "readable" permission.
37+
r :: Perm
2438
r = Perm { r: true, w: false, x: false }
39+
40+
-- | The "writable" permission.
41+
w :: Perm
2542
w = Perm { r: false, w: true, x: false }
43+
44+
-- | The "executable" permission.
45+
x :: Perm
2646
x = Perm { r: false, w: false, x: true }
2747

48+
-- | All permissions: readable, writable, and executable.
49+
all :: Perm
50+
all = r <> w <> x
51+
2852
instance semigroupPerm :: Semigroup Perm where
2953
(<>) (Perm { r = r0, w = w0, x = x0 }) (Perm { r = r1, w = w1, x = x1 }) =
3054
Perm { r: r0 || r1, w: w0 || w1, x: x0 || x1 }
@@ -51,9 +75,13 @@ permFromChar = _perm <<< charString
5175
_perm "7" = Just $ r <> w <> x
5276
_perm _ = Nothing
5377

78+
-- | Create a `Perm` value. The arguments represent the readable, writable, and
79+
-- | executable permissions respectively.
5480
mkPerm :: Boolean -> Boolean -> Boolean -> Perm
5581
mkPerm r w x = Perm { r: r, w: w, x: x }
5682

83+
-- | Create a `Perms` value. The arguments represent the user's, group's, and
84+
-- | others' permission sets, respectively.
5785
mkPerms :: Perm -> Perm -> Perm -> Perms
5886
mkPerms u g o = Perms { u: u, g: g, o: o }
5987

0 commit comments

Comments
 (0)