From aaf85b3ece465648aa30e60bb51fb46f931625fc Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 23 Dec 2020 14:14:32 +0700 Subject: [PATCH] Meta tweaks --- .github/workflows/main.yml | 24 ++++++++++++++++++++++++ .travis.yml | 7 ------- index.d.ts | 2 ++ index.js | 3 ++- readme.md | 2 +- 5 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b85fc2a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,24 @@ +name: CI +on: + - push + - pull_request +jobs: + test: + name: Node.js ${{ matrix.node-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: + - 14 + - 12 + - 10 + - 8 + - 6 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 81f3378..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: node_js -node_js: - - '14' - - '12' - - '10' - - '8' - - '6' diff --git a/index.d.ts b/index.d.ts index 314c5c8..bdd7df4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -24,6 +24,7 @@ declare namespace prettyBytes { @default false + @example ``` import prettyBytes = require('pretty-bytes'); @@ -38,6 +39,7 @@ declare namespace prettyBytes { @default false + @example ``` import prettyBytes = require('pretty-bytes'); diff --git a/index.js b/index.js index f6b5540..ee15bad 100644 --- a/index.js +++ b/index.js @@ -71,12 +71,13 @@ module.exports = (number, options) => { } options = Object.assign({bits: false, binary: false}, options); + const UNITS = options.bits ? (options.binary ? BIBIT_UNITS : BIT_UNITS) : (options.binary ? BIBYTE_UNITS : BYTE_UNITS); if (options.signed && number === 0) { - return ' 0 ' + UNITS[0]; + return ` 0 ${UNITS[0]}`; } const isNegative = number < 0; diff --git a/readme.md b/readme.md index fb65f0b..59e84ec 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# pretty-bytes [![Build Status](https://travis-ci.com/sindresorhus/pretty-bytes.svg?branch=master)](https://travis-ci.com/github/sindresorhus/pretty-bytes) +# pretty-bytes > Convert bytes to a human readable string: `1337` → `1.34 kB`