Skip to content

Commit 5247c29

Browse files
committed
Update README
1 parent fe3cee8 commit 5247c29

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,21 @@
33
[![downloads](https://img.shields.io/npm/dt/unix-permissions.svg?logo=npm)](https://www.npmjs.com/package/unix-permissions) [![last commit](https://img.shields.io/github/last-commit/ehmicky/unix-permissions.svg?logo=github&logoColor=white)](https://github.com/ehmicky/unix-permissions/graphs/contributors) [![license](https://img.shields.io/badge/license-Apache%202.0-4cc61e.svg?logo=github&logoColor=white)](https://www.apache.org/licenses/LICENSE-2.0) [![Coverage Status](https://img.shields.io/codecov/c/github/ehmicky/unix-permissions.svg?label=test%20coverage&logo=codecov)](https://codecov.io/gh/ehmicky/unix-permissions) [![travis](https://img.shields.io/travis/ehmicky/unix-permissions/master.svg?logo=travis)](https://travis-ci.org/ehmicky/unix-permissions/builds) [![npm](https://img.shields.io/npm/v/unix-permissions.svg?logo=npm)](https://www.npmjs.com/package/unix-permissions) [![node](https://img.shields.io/node/v/unix-permissions.svg?logo=node.js)](#) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?logo=javascript)](https://standardjs.com) [![eslint-config-standard-prettier-fp](https://img.shields.io/badge/eslint-config--standard--prettier--fp-4cc61e.svg?logo=eslint&logoColor=white)](https://github.com/ehmicky/eslint-config-standard-prettier-fp) [![Gitter](https://img.shields.io/gitter/room/ehmicky-code/unix-permissions.svg?logo=gitter)](https://gitter.im/ehmicky-code/unix-permissions)
44

55
[Unix file permissions](https://en.wikipedia.org/wiki/File_system_permissions)
6-
can take several [types](#types). With
7-
[`chmod`](https://linux.die.net/man/1/chmod) they
8-
look like either [`ug+rw`](#symbolic) or [`660`](#octal), while with
9-
[`stat`](https://linux.die.net/man/2/stat) and
10-
[`ls`](https://linux.die.net/man/1/ls) they look like [`drw-rw----`](#stat).
11-
This library enables using any of those [types](#types) (instead of being
6+
can take many [shapes](#types):
7+
[symbolic](#symbolic) (`ug+rw`), [octal](#octal) (`660`) or a [list of characters](#stat) (`drw-rw----`).
8+
This library enables using any of [these](#types) (instead of being
129
limited to a single one) with any [Node.js](#examples-javascript) or
1310
[CLI command](#examples-cli).
1411

15-
This library also allows you to perform operations on Unix permissions
16-
including:
12+
This library can also perform operations on Unix permissions such as:
1713

14+
- [testing](#containpermission-permissions),
15+
[setting](#setpermission-permissions) and
16+
[unsetting](#notpermission-permissions). Using bitwise operations (`|`,
17+
`&`, `^`, `~`) can be tedious and error-prone otherwise.
1818
- [validating](#normalizepermission) syntax.
1919
- [normalizing](#normalizepermission). For example `u+r,u+w` can be shortened
2020
to `u+rw`.
21-
- [testing](#containpermission-permissions), e.g. "Is this executable by any
22-
users?"
23-
- [setting](#setpermission-permissions) and
24-
[unsetting](#notpermission-permissions). Using bitwise operations (`|`,
25-
`&`, `^`, `~`) can be tedious and error-prone otherwise.
2621
- [inverting](#invertpermission). For example a
2722
[`umask`](https://linux.die.net/man/2/umask) of `117` means new files will be
2823
created with `661` permissions.
@@ -42,7 +37,8 @@ using those strings.
4237
<!-- eslint-disable handle-callback-err, node/prefer-global/process, no-sync -->
4338

4439
```js
45-
// Retrieve a file's permission as an object instead of a number
40+
// Retrieve a file's permission as an object like
41+
// `{ user: { write: false, read: true, ... }, ... }` instead of a number
4642
convert.object(fs.statSync('/etc/passwd').mode)
4743

4844
// Set a file's permission using `symbolic` notation instead of a number
@@ -54,7 +50,9 @@ fs.writeFile('/my/file', content, { mode: convert.number('a=r') })
5450
// Disallow executing new files using `umask`
5551
process.umask(convert.number(invert('a-x')))
5652

57-
// Allow your library's users to use any Unix permission type as input
53+
// If your library takes Unix permissions as input, using
54+
// `unix-permissions` under the hood lets your users choose their
55+
// favorite Unix permissions type.
5856
myLibrary.method({ mode: 'a-wx' })
5957
myLibrary.method({ mode: '444' })
6058
```
@@ -260,12 +258,15 @@ a+r
260258

261259
Returns `permission` converted to another [`type`](#types).
262260

263-
Note that [`symbolic`](#symbolic) and [`object`](#object) distinguish between
264-
leaving permissions as is (omitting them or using `undefined`) and unsetting
265-
them (using `-` or `false`). [`number`](#number) and [`stat`](#stat) do not
261+
Note that [`symbolic`](#symbolic) and [`object`](#object) distinguish between:
262+
263+
- leaving permissions as is (omitting them or using `undefined`)
264+
- unsetting them (using `-` or `false`).
265+
266+
[`number`](#number) and [`stat`](#stat) do not
266267
make this distinction. If you convert between them, you might lose this
267-
information as we assume `-` and `0` in [`number`](#number) and [`stat`](#stat)
268-
mean "unset permissions". However you can use
268+
information as we assume `0` in [`number`](#number) and `-` in
269+
[`stat`](#stat) mean "unset permissions". However you can use
269270
[`positive()`](#positivepermission) to overcome this issue.
270271

271272
<!-- eslint-disable line-comment-position, no-inline-comments -->
@@ -368,7 +369,7 @@ equal('o+x,o-w', 'o+x', 'o-w') // `false`
368369

369370
Returns the result of setting `permissions` on `permission`.
370371

371-
This is useful to avoid error-prone bitwise operations.
372+
This is useful to avoid error-prone bitwise operations (`|`, `&`, `^`, `~`).
372373

373374
This can also be used to remove special permissions using
374375
`set(permission, 'a-st')` since some functions like
@@ -427,7 +428,7 @@ invert('1660') // '0117'
427428

428429
## `min(permissions...)`
429430

430-
Retrieve the lowest permissions among all argument.
431+
Retrieve the lowest permissions among all arguments.
431432

432433
This does not return the lowest argument. Instead it returns a combination
433434
of the lowest bits of all arguments.

0 commit comments

Comments
 (0)