|
1 | | -# Format |
| 1 | +# Format [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL] |
2 | 2 |
|
3 | | -Library for format size, permissions, etc. |
| 3 | +Format size, permissions, etc. |
4 | 4 |
|
5 | 5 | # How to use? |
6 | 6 |
|
7 | 7 | Format could be used in browser or node. |
8 | 8 |
|
9 | | -In browser: |
10 | | - |
11 | 9 | ```js |
12 | | -<script src='lib/format.js'></script> |
13 | | -``` |
14 | | - |
15 | | -In node: |
16 | | - |
17 | | -```js |
18 | | -var Format = require('format-io'); |
| 10 | +const format = require('format-io'); |
19 | 11 | ``` |
20 | 12 |
|
21 | 13 | # API |
22 | 14 |
|
23 | 15 | ## size |
24 | 16 |
|
25 | 17 | ```js |
26 | | - var size = 1024 * 1024 * 5, |
27 | | - sizeStr = Format.size(size); |
28 | | - //'5.00mb' |
| 18 | +const size = 1024 * 1024 * 5; |
| 19 | +format.size(size); |
| 20 | +// returns |
| 21 | +'5.00mb' |
29 | 22 | ``` |
30 | 23 |
|
31 | 24 | ## permissions.symbolic |
32 | 25 |
|
33 | 26 | ```js |
34 | | - var perm = '00777', |
35 | | - permStr = Format.permissions.symbolic(perm); |
36 | | - //'rwx rwx rwx |
| 27 | +const perm = '00777'; |
| 28 | +format.permissions.symbolic(perm); |
| 29 | +// returns |
| 30 | +'rwx rwx rwx' |
37 | 31 | ``` |
38 | 32 |
|
39 | 33 | ## permissions.numeric |
40 | 34 |
|
41 | 35 | ```js |
42 | | - var perm = 'rwx rwx rwx', |
43 | | - permNum = Format.permissions.numeric(perm); |
44 | | - //'00777' |
| 36 | +const perm = 'rwx rwx rwx'; |
| 37 | +format.permissions.numeric(perm); |
| 38 | +// returns |
| 39 | +'00777' |
| 40 | +``` |
| 41 | + |
| 42 | +## Environments |
| 43 | + |
| 44 | +In environments that not supports `es2015`, `format` can be used with: |
| 45 | + |
| 46 | +```js |
| 47 | +var format = require('format/legacy'); |
45 | 48 | ``` |
46 | 49 |
|
47 | 50 | # License |
48 | 51 |
|
49 | 52 | MIT |
| 53 | + |
| 54 | +[NPMIMGURL]: https://img.shields.io/npm/v/format-io.svg?style=flat |
| 55 | +[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/format-io/master.svg?style=flat |
| 56 | +[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/format-io.svg?style=flat |
| 57 | +[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat |
| 58 | +[NPMURL]: https://npmjs.org/package/format-io "npm" |
| 59 | +[BuildStatusURL]: https://travis-ci.org/coderaiser/format-io "Build Status" |
| 60 | +[DependencyStatusURL]: https://david-dm.org/coderaiser/format-io "Dependency Status" |
| 61 | +[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License" |
| 62 | + |
| 63 | +[CoverageURL]: https://coveralls.io/github/coderaiser/format-io?branch=master |
| 64 | +[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/format-io/badge.svg?branch=master&service=github |
| 65 | + |
0 commit comments