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

array-flick

v0.1.2

Published

Never ending flick though circular arrays using next() / prev()

Downloads

20

Readme

array-flick Build Status

Never ending flick though arrays by using next() / prev()

Install

$ npm install array-flick

Usage

const Flick = require('array-flick');

const flick = new Flick(1,2,3)

flick.next(); // 1
flick.next(); // 2
flick.next(); // 3
flick.next(); // 1
flick.next(); // 2
flick.prev(); // 1
flick.prev(); // 3
flick.prev(); // 2

flick.random() // one of 1,2,3

Note there is also a setter for randomFn. again, useful for testing / seeding. Look at the specs to learn more.

API

new Flick(...values)

Behaves like an Array with next and prev methods added.

When writing database seeders and tests this expressiveness-sugar helps to make the intentions of the program easily recognizable.

next()

Type: Integer Default: 1

How many steps to flick forward. Defaults to 1.

const names = new Flick('Jim', 'Fin', 'Lin');

names.next()  // Jim
names.next(2) // Lin
names.next(2) // Fin

prev()

Type: Integer Default: 1

How many steps to flick backwards. Defaults to 1.

const names = new Flick('Jim', 'Fin', 'Lin');

names.prev()  // Lin
names.prev(2) // Jim
names.prev(2) // Fin

random()

const xos = new Flick(...(Array(99).fill('x').concat('o')));
xos.randomFn = () => 0.999; // generate your own (seeded) random floats 0..1 here
xos.random() // 'o'

Returns a random entry

randomFn (setter)

Useful for reproducible random return values, for example with the help of seedrandom

Contributing contributions welcome

License

MIT © iilei • Jochen Preusche