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

xwing-list-loader

v3.0.0

Published

Load lists in xws format from all popular X-Wing list builders

Downloads

8

Readme

xwing-list-loader

A simple Node module that takes squad builder URLs and returns the matching XWS JSON object.

Motivation

In several X-Wing projects I wanted to resolve a squad builder url to that squad's XWS object. I found myself copy-pasting snippets of code between projects that I later had to update every time I wanted to support a new endpoint. This wouldn't work in the long run so I created this module so I can build it once and re-use it everywhere.

Installation

Install using yarn or npm:

$ yarn add xwing-list-loader
$ npm install xwing-list-loader --save

API

load(url)

  • url A string representing the squad's URL
  • Returns: Promise<Object|False>

This method will first check if url matches any of the supported integrations. If so, it will parse the url, turn it into an URL that points to the XWS and perform a HTTP(S) request.

If valid XWS can be loaded from the given URL the promise will resolve with the XWS object.

The promise will resolve with false if:

  • The given URL does not match any of the supported integrations
  • The given URL does not return a valid XWS JSON object (= has no pilots or faction field)
  • The request to fetch the XWS was unsuccessful (a response with status code != 2xx)

The promise will be rejected if:

  • There are network/permission issues
  • The response cannot be parsed as JSON

Example:

import listLoader from 'xwing-list-loader';

const url =
  'https://raithos.github.io/?f=Galactic%20Republic&d=v8ZsZ200Z273XW2W201WY278XWW200WY333X123WWW&sn=Ani%2FObi%2FRic&obs=gascloud1,gascloud2,gascloud3';

// Using promises
listLoader.load(url).then(
  xws => {
    console.log(xws);
  },
  err => {
    console.error(err);
  }
);

// Using async/await
(async () => {
  try {
    const xws = await listLoader.load(url);
    console.log(xws);
  } catch (err) {
    console.error(err);
  }
})();

Supported integrations

URLs will be matched against the following endpoints (in order):

Second Edition:

  1. (Yet Another) Squad Builder 2
  2. Launch Bay Next (Android / iOS)
  3. Official FFG Squadbuilder
  4. Meta-Wing2

First Edition:

  1. (Yet Another) Squad Builder
  2. Voidstate
  3. Fab's Squadrons Generator
  4. Meta-Wing

License

MIT


Star Wars, X-Wing: The Miniatures Game and all related properties are owned by Fantasy Flight Games, Lucasfilm Ltd., and/or Disney.