Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Oct 27, 2019
1 parent d9be560 commit d77b3e5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions README.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ The object returned by `byteSize` defines a `toString` method therefore can be u
'Filesize: 12.4 kB'
```

Override the default `toString` behaviour by setting [`options.toStringFn`](https://github.com/75lb/byte-size#bytesizebytes-options--object-).
Override the default `toString` behaviour by setting [`options.toStringFn`](#bytesizebytes-options--object-).

```js
> function toStringFn () {
return `**${this.value}${this.unit}**`
}
return `**${this.value}${this.unit}**`
}

> `Filesize: ${byteSize(12400, { toStringFn })}`
'Filesize: **12.4kB**'
Expand Down Expand Up @@ -85,7 +85,7 @@ You can adjust the `precision`.
{ value: '2', unit: 'KiB', long: 'kibibytes' }
```

Define custom units by passing an object containing one or more additional conversion tables to `options.customUnits`.
Define custom units by passing an object containing one or more additional conversion tables to `options.customUnits`. In `options.units`, specify the name of a property from the `customUnits` object.

```js
> const customUnits = {
Expand All @@ -103,7 +103,7 @@ Define custom units by passing an object containing one or more additional conve
'10.0K'
```

Override the built-in defaults for the duration of the process by passing an options object to `byteSize.defaultOptions`. This results in cleaner code in cases where `byteSize` is used often with the same options.
Override the built-in defaults for the duration of the process by passing an options object to `byteSize.defaultOptions()`. This results in cleaner code in cases where `byteSize` is used often with the same options.

```js
> byteSize.defaultOptions({
Expand All @@ -123,7 +123,7 @@ Override the built-in defaults for the duration of the process by passing an opt
})

> [2400, 16400, 3991200].map(byteSize).join(', ')
2.40k, 16.40k, 3.99m
'2.40k, 16.40k, 3.99m'
```

{{>main}}
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ The object returned by `byteSize` defines a `toString` method therefore can be u
'Filesize: 12.4 kB'
```

Override the default `toString` behaviour by setting [`options.toStringFn`](https://github.com/75lb/byte-size#bytesizebytes-options--object-).
Override the default `toString` behaviour by setting [`options.toStringFn`](#bytesizebytes-options--object-).

```js
> function toStringFn () {
return `**${this.value}${this.unit}**`
}
return `**${this.value}${this.unit}**`
}

> `Filesize: ${byteSize(12400, { toStringFn })}`
'Filesize: **12.4kB**'
Expand Down Expand Up @@ -85,7 +85,7 @@ You can adjust the `precision`.
{ value: '2', unit: 'KiB', long: 'kibibytes' }
```

Define custom units by passing an object containing one or more additional conversion tables to `options.customUnits`.
Define custom units by passing an object containing one or more additional conversion tables to `options.customUnits`. In `options.units`, specify the name of a property from the `customUnits` object.

```js
> const customUnits = {
Expand All @@ -103,7 +103,7 @@ Define custom units by passing an object containing one or more additional conve
'10.0K'
```

Override the built-in defaults for the duration of the process by passing an options object to `byteSize.defaultOptions`. This results in cleaner code in cases where `byteSize` is used often with the same options.
Override the built-in defaults for the duration of the process by passing an options object to `byteSize.defaultOptions()`. This results in cleaner code in cases where `byteSize` is used often with the same options.

```js
> byteSize.defaultOptions({
Expand All @@ -123,7 +123,7 @@ Override the built-in defaults for the duration of the process by passing an opt
})

> [2400, 16400, 3991200].map(byteSize).join(', ')
2.40k, 16.40k, 3.99m
'2.40k, 16.40k, 3.99m'
```

<a name="module_byte-size"></a>
Expand All @@ -132,7 +132,7 @@ Override the built-in defaults for the duration of the process by passing an opt

* [byte-size](#module_byte-size)
* [byteSize(bytes, [options])](#exp_module_byte-size--byteSize) ⇒ <code>object</code> ⏏
* [.defaultOptions([options])](#module_byte-size--byteSize.defaultOptions)
* [.defaultOptions(options)](#module_byte-size--byteSize.defaultOptions)

<a name="exp_module_byte-size--byteSize"></a>

Expand All @@ -152,14 +152,14 @@ Returns an object with the spec `{ value: string, unit: string, long: string }`.

<a name="module_byte-size--byteSize.defaultOptions"></a>

#### byteSize.defaultOptions([options])
#### byteSize.defaultOptions(options)
Set the default `byteSize` options for the duration of the process.

**Kind**: static method of [<code>byteSize</code>](#exp_module_byte-size--byteSize)

| Param | Type | Description |
| --- | --- | --- |
| [options] | <code>object</code> | A `byteSize` options object. |
| options | <code>object</code> | A `byteSize` options object. |


## Load anywhere
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@

/**
* Set the default `byteSize` options for the duration of the process.
* @param [options] {object} - A `byteSize` options object.
* @param options {object} - A `byteSize` options object.
*/
byteSize.defaultOptions = function (options) {
defaultOptions = options;
Expand Down
2 changes: 1 addition & 1 deletion index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function byteSize (bytes, options) {

/**
* Set the default `byteSize` options for the duration of the process.
* @param [options] {object} - A `byteSize` options object.
* @param options {object} - A `byteSize` options object.
*/
byteSize.defaultOptions = function (options) {
defaultOptions = options
Expand Down

0 comments on commit d77b3e5

Please sign in to comment.