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

daystobits

v1.0.3

Published

A simple utility to convert weekly days to bit values for database storage.

Downloads

36

Readme

Days-To-Bits

About

Days-To-Bits is a simple and performant package that aims to lessen the complicatedness of storing an array of 0-based weekday values as a singular int within a database. You can access a current simple demo.

What does this solve?

Why would anyone store an array of 0-based weekday values as in int? Well, it has everything to do with database storage and performance. Take for example const days = [0, 1, 4, 6]. It would usually be stored as [0,1,4,6] in the database as a JSON Object. This clearly takes up a lot of space compared to the decimal value 102. If you unpack 102 you will get an array of numbers which equals [0,1,4,6]. Cool, right?

How to install and use

First, make sure you have a package.json file and your project has been initialized. Please do some research before you install this package. Every package you add to a project is future technical debt.

npm i daystobits
import Bit, { FULL, SHORT, NUMBERS } from 'daystobits'

... your code

Bit.packDays([0,1,4,6]) // 102
Bit.unpackDays(102, NUMBERS) // [0,1,4,6]
Bit.unpackDays(102, FULL) // ["Sunday","Monday","Tuesday","Thursday","Friday"]
Bit.unpackDays(102, SHORT) // ["Sun","Mon","Tue","Thu","Fri"]

Support

I offer no warranty or support of this code. This is open source package and is aimed at reducing the development time of junior developers. Please note that I take no responsibility of security issues or performance costs.

Contributing

Please help make this better! The aim is to make stuffing date related data into decimal format easy for the common developer. Currently, this only handles 0-based days-of-week. It would be nice to handle more use-cases. Please email [email protected] for more information.

Roadmap

  • [ ] Demo Site
  • [ ] Updated and In-Depth Docs
  • [ ] DEV.to article explaining how this works in-depth
  • [ ] Add use-cases

License

This project uses the standard MIT License. PLease read it within the src files at ./license.txt