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

assembly-line.js

v1.0.1

Published

Tools for Assembly Line (the game)

Downloads

6

Readme

AssemblyLine.js

Assembly Line (the game) tools.

Installation

npm install assembly-line.js

Usage

const AL = require('assembly-line.js');

Recipe (and RecipeGen)

Creating a recipe / RecipeGen(arr)

RecipeGen returns a recipe, generated based on the resources you pass.

The array arr should be an array of resouce prototypes (that is, like AL.Aluminum and not new AL.Aluminum())

If you need more than one of the same item, repeat it in the array. (See: Resource.repeat())

Don't provide None, it will be automatically filled.

ingredients

The getter returns an array of resource prototypes like you would have put in RecipeGen

The setter works exactly like RecipeGen.

toString(isMultiline)

toString by default returns a multiline string with a pink-colored Recipe followed by brac, newline, list of materials on seperate lines and closing brace.

Setting the first argument (isMultiline) to false returns a single-line version of the same string, but with parentheses instead of braces.

equal(other)

Checks whether two recipes share the same ingredients, in the same amount and in the same order.

Resource

All members of Resource and subclasses are static.

isRoot

Whether the resource is a 'root' resource (Aluminum, Copper, Diamond, Gold, Iron and None).

sellCost

Value when sold.

repeat(n)

Repeats the resource n times, and returns an array.

AL.Circuit.repeat(3)
          .map(i => {return i.toString()})
          .forEach(i => {console.log(i)})
/* →
Circuit(300$)
Circuit(300$)
Circuit(300$)
*/

toString(level)

Returns a string representation of the resource.

level defaults to 1 and is used to choose the amount of color and formatting in the string.

Suggested:

  • 0 for when you are using a string inside of another function which returns a string (one line, all default color)
  • 1 for when you are using a string for logging basic information (one line, colored)
  • 2 for when you want formatted and extensive logging, like for debugging purposes (multiline, colored)

Resources in the library

By default, the library contains all the resources in Assembly Line, including None. They are named with this convention:

  • get the item's name
  • Make It Title Case
  • RemoveSpaces

(To reformat into the original name, you can use String.prototype.unCamel() which does the steps in reverse and turns A I into AI.)

Calculations

howMany(toCalc, res)

Given two resources toCalc and res, calculate how many ress there are in toCalc's recipes.

AL.howMany(AL.AIRobot, AL.Circuit);
// → 1030

howManyMultiple(toCalc, res)

Given a resource toCalc and an array of resources res, calculate how many of each res's items there are in toCalc's recipes.

AL.howManyMultiple(AL.AIRobot, [AL.Circuit, AL.Engine]);
// → { Circuit: 1030, Engine: 560 }

howManyRoots(toCalc)

Given a resource toCalc, calculate how many of each of the root items (excluding None) there are in toCalc's recipes.

This is a wrapper around howManyMultiple

AL.howManyRoots(AL.AIRobot);
// { Aluminum: 2920, Copper: 2495, Diamond: 0, Gold: 1665, Iron: 1480 }

License

MIT