npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bytes-and-bits-converter

v0.1.6

Published

A calculator designed to convert between different units of measurement for bits and bytes, such as kilobytes to bytes, and so on.

Downloads

2

Readme

Note: I am not a software developer. This project was made solely and exclusively for personal learning purposes. I would greatly appreciate it if you could send me criticisms, tips, suggestions, and any other comments that may help me to evolve.

A library to convert magnitudes

Examples:

  • Bits to Bytes
  • Bytes to Bits
  • Handle and convert different unit types: Binary (Kibi, Mebi, etc) and Decimal (Kilo, Mega, etc)

Description:

The chosen approach in this library is to convert the input value to bits, regardless of the system (Binary or Decimal), magnitude (Mega, Mebi, Giga, Tebi, etc.), or type (Bytes or Bits) it came in, and then convert the raw bit value to the final unit selected by the user.

How to use:

Back-end implementation:

Install the library from NPM:

npm i bytes-and-bits-converter

For Node.js, import the library as follows:

const calculator = require('calculator')

Inside the demo folder, YOUR-NODE-CODE.js provide a simple example of how to use the library on the back-end.

If you're using node type as ES Modules, you'll need to comment all "require" and "module.exports" from the .js files, and uncomment the "import" and "export" lines.

Front-end implementation:

Install the library from NPM:

npm i bytes-and-bits-converter

Copy the /src folder and script.js file from /node_modules to your working directory.

In order to work on a browser, you'll need to make some changes in these files:

./script.js
./src/calculator.js
./src/help.js
./unitReferences.js

All you need to do is comment the lines using "require" or "module.exports" and uncomment the lines using "import" and "export", like this example on calculator.js:

import { unitReferences } from './unitReferences.js'
// const unitReferences = require('./unitReferences')
...
export {calculator}
// module.exports = calculator

If you want to use this project inside your .js file, import the library as follows:

import { calculator } from "./script.js"

If you want to use this project right through your HTML file, import the library at the end of the <body> tag, as follows:

<body>
...your html code...
<script src="./script.js" type="module"></script
</body>

Inside the demo folder, index.html and YOUR-FRONTEND-CODE.js provides an example of how to use the libray on the front-end.

Changelog:

Last updates: ## [0.1.6] - 2023-05-18

Updating "type" from ES Modules to CommonJS.

Added:

  • On all .js files, added const xx = require('') and module.exports in order to work as CommonJS.
  • On all .js files, added commented import and export lines to facilitate any potential change on node type to ES Modules.

View complete history