https://github.com/danielkov/prettybits
📟 Mini library for pretty printing bits and bytes
https://github.com/danielkov/prettybits
Last synced: about 1 year ago
JSON representation
📟 Mini library for pretty printing bits and bytes
- Host: GitHub
- URL: https://github.com/danielkov/prettybits
- Owner: danielkov
- License: mit
- Created: 2020-02-21T21:07:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T07:57:54.000Z (over 3 years ago)
- Last Synced: 2025-04-08T22:02:02.628Z (about 1 year ago)
- Language: TypeScript
- Size: 1.61 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 📟 prettybits
Mini library for pretty printing bits and bytes.
This project was bootstrapped with [this template](https://github.com/danielkov/single-package).
## Get started
```sh
npm install --save prettybits
```
or
```sh
yarn add prettybits
```
## Usage
Pretty print bytes:
```ts
import { bytes } from 'prettybits';
console.log(bytes(-11234)); // > -11.2 kB
console.log(bytes(0)); // > 0 B
console.log(bytes(11234)); // > 11.2 kB
console.log(bytes(3284751)); // > 3.28 MB
```
Pretty print bits:
```ts
import { bits } from 'prettybits';
console.log(bits(-11234)); // > -11.2 kbit
console.log(bits(0)); // > 0 b
console.log(bits(11234)); // > 11.2 kbit
console.log(bits(3284751)); // > 3.28 Mbit
```
## Contributing
Thank you for wanting to contribute. Before you get started, [read our contribution guidelines](CONTRIBUTING.md).
To get started, fork the repository and then clone it to your machine. You will need Node JS v8+ and NPM to run the project.
To grab all the dependencies for development:
```sh
npm install
```
Run tests in watch mode:
```sh
npm test -w
```
Once you're happy with your changes, use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard to create your commit messages.
To build the package, use the command:
```sh
npm build
```
If all seems good and tests are green, push your changes and submit a pull request.