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

playlist-combinator

v0.0.7

Published

A thing to mix up users and their playlists.

Downloads

23

Readme

playlist-combinator

Build Status Dependency Status devDependency Status

A javascript module to rotate through multiple users' music queues.

usage

Run this code:

var playlist = require('playlist-combinator')()
playlist.on('error', function (err) {
	console.log(err)
})

playlist.addUser('Wheatley', [ 'accent' ])
playlist.addUser('GLaDOS')

playlist.addSong('GLaDOS', 'potato')
playlist.addSong('GLaDOS', 'neurotoxin')
playlist.addSong('GLaDOS', 'Caroline')

Internally:

userOrder: ['GLaDOS', 'Wheatley']
songs: {
	"Wheatley": [ 'accent' ],
	"GLaDOS": [ 'potato', 'neurotoxin', 'Caroline' ]
}

Run this code:

var song = playlist.getNextSong() //returns => 'potato'

Internally:

userOrder: ['Wheatley', 'GLaDOS'] //note that GLaDOS was moved to the back; and it's Wheatley's turn next
songs: {
	"Wheatley": [ 'accent' ]
	"GLaDOS": [ 'neurotoxin', 'Caroline' ]
}

Run this code:

var song = playlist.getNextSong() //returns => 'accent'
var song = playlist.getNextSong() //returns => 'neurotoxin'
var song = playlist.getNextSong() //returns => 'Caroline'

api

var PlaylistCombinator = require('playlist-combinator')

var playlist = PlaylistCombinator()

var song = playlist.getNextSong()

  • Removes the first song from the first user's queue.
  • Moves the first user to the back of the user list.
  • Returns the song object.

var song = playlist.checkNextSong()

Basically playlist.getNextSong() but this does not mutate the playlist.

  • Returns the first song from the first user's queue.

playlist.addSong(userId, song)

  • userId is a string. Each user must have their own unique string. The userId must have been added via playlist.addUser(userId) previous to calling this.
  • song is any object.

playlist.reorderSong(userId, newArray)

This is the suggested way to reorder songs. This is not the suggested way to add or remove songs, although it is completely allowed.

  • userId is a string. Each user must have their own unique string. The userId must have been added via playlist.addUser(userId) previous to calling this.
  • newArray is an array of song ids in the new order. You can remove songs, add songs, and reorder songs.

playlist.reorderSong(userId, songId, newQueueLocationIndex)

This is not the suggested way to reorder songs.

  • userId is a string. Each user must have their own unique string. The userId must have been added via playlist.addUser(userId) previous to calling this.
  • songId is compared to each song.id in the queue. This is the only place that song.id is assumed to exist.
  • newQueueLocationIndex is the number that the located song is relocated to.

playlist.addUser(userId, userState)

  • userId is a string. Each user must have their own unique string. The userId must have been added via playlist.addUser(userId) previous to calling this.
  • userState is an optional argument. It must come from playlist.removeUser().

var userState = playlist.removeUser(userId)

  • Returns a userState object. This object can be passed into playlist.addUser() to start a new user with the same state that this user gave up. This could be used for changing a userId without losing their state, or saving a user's state for later use.

license

VOL