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

zeppo

v1.6.0

Published

Convert between numbers of different bases.

Downloads

222

Readme

ZEPPO :crystal_ball: :guitar:

GitHub CI

Convert between numbers of different bases. :crystal_ball: :guitar:

ABOUT :books:

Roughly a year ago, I set myself the challenge of implementing a set of functions that could convert between numbers of different bases. I implemented this in Dart and decided to re-write this implementation in Javascript. The Dart implementation can be found here. The bases this library handles are: base 10, base 2, and base 16.

USAGE :hammer:

Use Zeppo in a Node.js project

To use Zeppo in a Node.js project, run this command in your project's root directory:

$ npm install --save-dev zeppo

Be sure to also add the "type":"module" flag to your project's manifest, package.json.

Use Zeppo in a Node.js project with Typescript

Add a file called zeppo.d.ts to your project and put the following code inside it:

declare module 'zeppo';

APIs

Zeppo offers the following functions:

  • reverseArray(array): Reverses the order of an array and returns the reversed array.
  • letterIndex(letter): Gets the index of a letter in the alphabet. Returns zero if the letter isn't in the alphabet.
  • getLetterFromIndex(index): Gets the letter from a supplied index. Returns an empty string if a letter cannot be found.
  • binToDec(binaryNumber): Converts a base 2 number to a base 10 number.
  • decToBin(decimalNumber): Converts a base 10 number to a base 2 number.
  • hexToDec(hexNumber): Converts a base 16 number to a base 10 number.
  • isBin(expr): Checks whether the supplied string is a binary number or not.
  • isInt(expr): Checks whether the supplied string is an integer or not.
  • testAll(): Tests all of the above.

Example

Here's a small example:

  • 1.) Initialize a new Node.js project with the following command in a directory of your choosing:
$ npm init -y 
  • 2.) Install Zeppo:
$ npm install --save-dev zeppo
  • 3.) Be sure to add this line to your project's package.json:
"type":"module",
  • 4.) Create your index.js and put the following code inside it:
// index.js
import * as zeppo from 'zeppo';

function main(){
  var myNum = 21;
  console.log(zeppo.decToBin(myNum));
  // Should output 21.
  console.log(zeppo.binToDec(decToBin(myNum)));
}

main();
  • 5.) Run the project:
$ node .
  • 6.) Optional: If you're not sure how to use this project, check out the example project.

CHANGELOG :black_nib:

Version 1.0.0

  • Initial release.
  • Upload to GitHub.
  • Upload to NPM.

Version 1.1.0

  • New license file.
  • Better documentation.

Version 1.2.0

  • Updated documentation.
  • Added a function to check whether a string is a binary number or not.

Version 1.3.0

  • Updated documentation.
  • Added a function to check whether a string is an integer or not.

Version 1.4.0

  • Updated documentation.
  • Updated, published, and uploaded under my new name.

Version 1.5.0

  • Fixed some administrative issues.
  • Fixed some formatting issues.

Version 1.6.0

  • Updated export statement.
  • Updated documentation for Typescript.

NOTE :scroll:

  • Zeppo :crystal_ball: :guitar: by Alexander Abraham :black_heart: a.k.a. "Angel Dollface" :dolls: :ribbon:
  • Licensed under the MIT license.