11# API
22
3- The following methods are available both in
4- [ JavaScript] ( ../README.md#usage-javascript ) and on the
5- [ command line] ( ../README.md#usage-cli ) .
3+ The following methods are available in
4+ [ JavaScript] ( ../README.md#usage-javascript ) .
65
76You can try all the examples below:
87
9- - either directly [ in your browser] ( https://repl.it/@ehmicky/unix-permissions ) .
8+ - either directly
9+ [ in your browser] ( https://repl.it/@prantlf/unix-permissions-lib ) .
1010- or by executing the [ ` examples ` files] ( ../examples/README.md ) in a terminal.
1111
1212All methods (except [ ` type() ` ] ( #typepermission ) ) throw an exception if the
@@ -30,7 +30,7 @@ mean "unset permissions". However you can use
3030[ ` positive() ` ] ( #positivepermission ) to overcome this issue.
3131
3232``` js
33- import { convert } from ' unix-permissions'
33+ import { convert } from ' unix-permissions-lib '
3434
3535console .log (convert .symbolic (' 111' )) // 'a=x'
3636console .log (positive (convert .symbolic (' 111' ))) // 'a+x'
4949Returns the ` permission ` 's [ ` type ` ] ( types.md ) or ` 'invalid' ` .
5050
5151``` js
52- import { type } from ' unix-permissions'
52+ import { type } from ' unix-permissions-lib '
5353
5454console .log (type (' 1' )) // 'octal'
5555console .log (type (1 )) // 'number'
@@ -64,7 +64,7 @@ Normalizes a `permission` to its canonical shape.
6464Throws an exception if ` permission ` is invalid.
6565
6666``` js
67- import { normalize } from ' unix-permissions'
67+ import { normalize } from ' unix-permissions-lib '
6868
6969console .log (normalize (' 1' )) // '0001'
7070console .log (normalize (' g+x,o+x' )) // 'go+x'
@@ -86,7 +86,7 @@ Removes all negative permissions. See
8686explanation.
8787
8888``` js
89- import { positive , invert } from ' unix-permissions'
89+ import { positive , invert } from ' unix-permissions-lib '
9090
9191console .log (positive (' o+x,o-rw' )) // 'o+x'
9292console .log (positive (' o=x' )) // 'o+x'
@@ -99,10 +99,10 @@ console.log(invert(positive('660'))) // '-0660'
9999
100100Tests whether ` permission ` includes ` permissions ` .
101101
102- Returns ` true ` or ` false ` or (on the CLI) use the exit code ` 0 ` or ` 1 ` .
102+ Returns ` true ` or ` false ` .
103103
104104``` js
105- import { contain } from ' unix-permissions'
105+ import { contain } from ' unix-permissions-lib '
106106
107107console .log (contain (' --x--x--x' , ' a=x' )) // `true`
108108console .log (contain (' --x--x--x' , ' a+x' )) // `true`
@@ -120,10 +120,10 @@ console.log(contain('o+x,o-w', 'o+x', 'o-w')) // `true`
120120
121121Tests whether ` permission ` equals exactly ` permissions ` .
122122
123- Returns ` true ` or ` false ` or (on the CLI) use the exit code ` 0 ` or ` 1 ` .
123+ Returns ` true ` or ` false ` .
124124
125125``` js
126- import { equal } from ' unix-permissions'
126+ import { equal } from ' unix-permissions-lib '
127127
128128console .log (equal (' --x--x--x' , ' a=x' )) // `true`
129129console .log (equal (' --x--x--x' , ' a+x' )) // `false`
@@ -148,7 +148,7 @@ This can also be used to remove special permissions using
148148[ ` umask ` ] ( https://linux.die.net/man/2/umask ) do not allow them.
149149
150150``` js
151- import { set } from ' unix-permissions'
151+ import { set } from ' unix-permissions-lib '
152152
153153console .log (set (' ---------' , ' a+x' )) // '--x--x--x'
154154console .log (set (' ---------' , ' a+x' , ' a+r' )) // 'r-xr-xr-x'
@@ -165,7 +165,7 @@ This can be used in combination with `set()` to unset `permissions` instead of
165165setting them.
166166
167167``` js
168- import { not , set } from ' unix-permissions'
168+ import { not , set } from ' unix-permissions-lib '
169169
170170console .log (not (' u+xs' )) // 'u-xs'
171171console .log (not (' u-xs' )) // 'u+xs'
@@ -187,7 +187,7 @@ For example a [`umask`](https://linux.die.net/man/2/umask) of `117` means new
187187files will be created with ` 661 ` permissions.
188188
189189``` js
190- import { invert } from ' unix-permissions'
190+ import { invert } from ' unix-permissions-lib '
191191
192192console .log (invert (' u+xs' )) // 'u-x'
193193console .log (invert (' u-xs' )) // 'u+x'
@@ -209,7 +209,7 @@ This can be useful if you are looking for the lowest permission of a several
209209files, e.g. during a directory recursion.
210210
211211``` js
212- import { min } from ' unix-permissions'
212+ import { min } from ' unix-permissions-lib '
213213
214214console .log (min (' 404' , ' 440' , ' 402' )) // '0400'
215215```
@@ -219,7 +219,7 @@ console.log(min('404', '440', '402')) // '0400'
219219Inverse of [ ` min() ` ] ( #minpermissions ) .
220220
221221``` js
222- import { max } from ' unix-permissions'
222+ import { max } from ' unix-permissions-lib '
223223
224224console .log (max (' 404' , ' 440' , ' 402' )) // '0446'
225225```
0 commit comments