]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/umask/README.md
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / umask / README.md
1 # umask
2
3 Convert umask from string <-> number.
4
5 ## Installation & Use
6
7 ```
8 $ npm install -S umask
9
10 var umask = require('umask');
11
12 console.log(umask.toString(18));        // 0022
13
14 console.log(umask.fromString('0777'))   // 511
15 ```
16
17 ## API
18
19 ### `toString( val )`
20
21 Converts `val` to a 0-padded octal string.  `val` is assumed to be a
22 Number in the correct range (0..511)
23
24 ### `fromString( val, [cb] )`
25
26 Converts `val` to a Number that can be used as a umask.  `val` can
27 be of the following forms:
28
29   * String containing octal number (leading 0)
30   * String containing decimal number
31   * Number
32
33 In all cases above, the value obtained is then converted to an integer and
34 checked against the legal `umask` range 0..511
35
36 `fromString` can be used as a simple converter, with no error feedback, by
37 omitting the optional callback argument `cb`:
38
39 ```
40    var mask = umask.fromString(val);
41
42    // mask is now the umask descibed by val or
43    // the default, 0022 (18 dec)
44 ```
45
46 The callback arguments are `(err, val)` where `err` is either `null` or an
47 Error object and `val` is either the converted umask or the default umask, `0022`.
48
49 ```
50    umask.fromString(val, function (err, val) {
51        if (err) {
52           console.error("invalid umask: " + err.message)
53        }
54
55        /* do something with val */
56    });
57 ```
58
59 The callback, if provided, is always called **synchronously**.
60
61 ### `validate( data, k, val )`
62
63 This is a validation function of the form expected by `nopt`.  If
64 `val` is a valid umask, the function returns true and sets `data[k]`.
65 If `val` is not a valid umask, the function returns false.
66
67 The `validate` function is stricter than `fromString`: it only accepts
68 Number or octal String values, and the String value must begin with `0`.
69 The `validate` function does **not** accept Strings containing decimal
70 numbers.
71
72 # Maintainer
73
74 Sam Mikes <smikes@cubane.com>
75
76 # License
77
78 MIT