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

second-randomizer

v1.0.1

Published

This package features some utility functions that generate non-discrete seconds. This is useful whenever you need to humanize certain automated processes such as web scraping for example.

Downloads

4

Readme

Second Randomizer


This package contains a few utility functions that allow you to take a second and humanize it a bit.

For example:

import { randomizeSecond } from "./second-randomizer.js";

const randomizedSecond = randomizeSecond(1);

console.log({ randomizedSecond });

// { randomizedSecond: 975.730082482701 });

So, in essence, randomizeSecond simply takes 1 second or 10 seconds and either shaves a few milliseconds or nanoseconds off the top or tops it off.

If you want to take things a step further, then you might find getRandomizedSeconds useful.

const randomizedSeconds = getRandomizedSeconds(20);

console.log({ randomizedSeconds });

{ randomizedSeconds: [ 674.9023335706249, 1739.8147307171562, 2966.3398933132066, 3931.638644553672, 4927.24486384487, 6000.514162584786, 6974.802265200363, 8039.973875741117, 8991.489275703583, 9976.640062397237, 10985.187679168035, 12490.107286345026, 13093.68498379735, 13644.737910288986, 15058.262001511224, 16003.260647495856, 16993.810075548383, 18021.916929155155, 18584.34425820884, 19925.51333804717 ] }

As you can observe, you simply enter the number of seconds that you want to randomize, and getRandomizeSeconds will iterate from 1 to said number of seconds and randomize each second.

In a similar fashion to randomizeSecond, getRandomizedSecond will pluck a second at random from an array of seconds generated and randomized by getRandomizedSeconds.

const randomlyChosenSecond = getRandomizedSecond(20);

console.log({ randomlyChosenSecond });

{ randomlyChosenSecond: 11067.731749511813 };

Installation

NPM: npm install second-randomizer

Yarn: yarn add second-randomizer


Enjoy! If you have any suggestions or changes, just submit an issue or a pull request!