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

weeksjs

v1.0.2

Published

I was supposed to create a list of the days of the week from which an event would happen and I needed something simple. I didn't find anything that pleased me, so I noticed that the binaries could help me, and I hope they help you too, this was all very n

Downloads

5

Readme

Motivation

I was supposed to create a list of the days of the week from which an event would happen and I needed something simple. I didn't find anything that pleased me, so I noticed that the binaries could help me, and I hope they help you too, this was all very new to me. , I did not believe this would be possible only with NxN relations to solve my problem, so with the help of colleagues and friends, we identified that operator BITWISE would solve our problem with the days of the week and a special holiday day.

How Works

The library is given a number that is a sum of the active binaries relative to the table.

Table.

The days of the week are represented by each column of the table, the values ​​being Sunday = 1, Monday = 2, Tuesday = 4, Wednesday = 8 ... From this it is possible to use the bitwise operator to divide this integer, thus extracting the active days of the week.

https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators

Install

$ npm install --save weekjs

ES6

import React, {  useEffect } from 'react';
import weeksjs from 'weekjs';

export default props => {

	useEffect(() => {
		// ---------- Function getDaysOfWeek ---------- 
        console.log(weeksjs.getDaysOfWeek());
        // {
        // {day: "sunday", value: 1}
        // {day: "monday", value: 2}
        // {day: "tuesday", value: 4}
        // {day: "wednesday", value: 8}
        // {day: "thursday", value: 16}
        // {day: "friday", value: 32}
        // {day: "saturday", value: 64}
        // {day: "holiday", value: 128}
        // };


        // ---------- Function intToWeek ---------- 
        console.log(weeksjs.intToWeek(255);
        // {
        //     friday: true
        //     holiday: false
        //     monday: true
        //     saturday: false
        //     sunday: true
        //     thursday: true
        //     tuesday: true
        //     wednesday: true
        // } 
        console.log(weeksjs.weekToInt({
            monday: true,
            wednesday: true,
            saturday: true
        }));
        // //or
        console.log(weeksjs.weekToInt(["monday", "wednesday", "saturday"]));
	}, []);

	return null;
}

Browser

<!DOCTYPE html>
<html>
    <head>
        <meta charest="utf-8" />
        <title>WeeksJS!</title>
    </head>
	<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/weeksjs.umd.js">
    </script>
    <script>

        // ---------- Function getDaysOfWeek ---------- 
        console.log(weeksjs.getDaysOfWeek());
        // {
        // {day: "sunday", value: 1}
        // {day: "monday", value: 2}
        // {day: "tuesday", value: 4}
        // {day: "wednesday", value: 8}
        // {day: "thursday", value: 16}
        // {day: "friday", value: 32}
        // {day: "saturday", value: 64}
        // {day: "holiday", value: 128}
        // };


        // ---------- Function intToWeek ---------- 
        console.log(weeksjs.intToWeek(255, {
            array: true
        }));
        // {
        //     friday: true
        //     holiday: false
        //     monday: true
        //     saturday: false
        //     sunday: true
        //     thursday: true
        //     tuesday: true
        //     wednesday: true
        // } 


        console.log(weeksjs.weekToInt({
            monday: true,
            wednesday: true,
            saturday: true
        }));
        // return 74
        // //or
        console.log(weeksjs.weekToInt(["monday", "wednesday", "saturday"]));
        // return 74

    </script>
</html>

###Tables

| Functions | Description | | ------------- | ------------------------------ | | getDaysOfWeek() | return { "day" : "monday", value: 1 } | | intToWeek( sum, options ) | Pass as the sum of your binaries and receive an object representing the days of the week { "sunday" : true, monday:true,.. } | | weekToInt( object || array ) | Search the binary values ​​of the entered days and perform a sum. int |

| intToWeek | Description | | ------------- | ------------------------------ | | sum | The binary sum of the selected days | | options.array | Returns the Object Result changed to Array[Object] |

| weekToInt | Description | | ------------- | ------------------------------ | | object | { { "monday": true, "holiday": true} } | | array | ["monday", "holiday"] |


Use case (lang: PT-br)

Olá Ônibus - Application for transport public in Campo Mourão City.


End, Thank you for getting here Thanks Google translator