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

nitro-type.js

v2.0.4

Published

A library for interacting with the unofficial Nitro Type API.

Downloads

2

Readme

nitro-type.js

A library for interacting with the unofficial Nitro Type API.

This library consists only of GET requests; no POST requests are included.

Core Contents

These are the core features of this package.

/**
 * Fetches data generated by the Nitro Type NTBOOTSTRAP() function.
 * @param {Object} [options] - Additional options.
 * @param {Boolean} [options.raw=false] - Whether or not to return the data raw from the Nitro Type NTBOOTSTRAP() function.
 * @returns {Promise} Resolves to an Object containing Nitro Type data (this includes, but is not limited to: car, sticker, and achievement data).
 */
module.exports.bootstrap = function(options) {
  return new Promise(async (resolve, reject) => {
    // ...
  })
}
/**
 * Fetches data on the specified racer.
 * @param {String} username - The username of the user you want to search for.
 * @returns {Promise} Resolves to an Object containing data on the racer.
 */
module.exports.fetchRacerData = function(username) {
  return new Promise(async (resolve, reject) => {
    // ...
  })
}
/**
 * Fetches data on the specified team.
 * @param {String} tag - The tag of the team you want to search for.
 * @returns {Promise} Resolves to an Object containing data on the team.
 */
module.exports.fetchTeamData = function(tag) {
  return new Promise(async (resolve, reject) => {
    // ...
  })
}
/**
 * Fetches data on the last twenty news posts.
 * @returns {Promise} Resolves to an Object containing data on last twenty news posts.
 */
module.exports.fetchNewsPosts = function() {
  return new Promise(async (resolve, reject) => {
    // ...
  })
}
/**
 * Fetches data on the given news post.
 * @param {String|Number} id - The ID of the news post.
 * @returns {Promise} Resolves to an Object containing data on the news post.
 */
module.exports.fetchNewsData = function(id) {
  return new Promise(async (resolve, reject) => {
    // ...
  })
}

Additional Contents

These functions take the Core Contents and turn them into something more immediately useful.

/**
 * @param {String|Number} searchTerm - The name or ID of the car that you want to fetch data on.
 * @param {Object} [options] - Additional options.
 * @param {Boolean} [options.case_sensitive=true] - Whether or not the search should be case sensitive.
 * @peram {Boolean} [options.exact_match=true] - Whether or not the search should be an exact match. If set to false, the car name can simply include the searchTerm rather than both being exactly equal. Setting this to false will also force options.case_sensitive to set to false.
 * @returns {Promise} Resolves to an array of Objects that contain data on each result.
 */
module.exports.fetchCarData = function(searchTerm, options) {
  return new Promise(async (resolve, reject) => {
    // ...
  })
}

Examples

You can demo any of these examples by pasting and running them here.

async function example() {
  const nitrotype = require("nitro-type.js");

  try { //a try-catch statement for error handling
    await nitrotype.fetchRacerData("corndog").then(async data => {
      let carURL; // declares a variable to store the image URL
      if (data.carHueAngle == 0) { // cars with the default paint job have a different link format than those that are painted
        carURL = (await nitrotype.NTBOOTSTRAP()).filter(array => array[0] == "CAR_URL")[0][1]; // fetches the car URL that non-painted cars use ("https://www.nitrotype.com/cars/") and reassigns it to carURL
        carURL = carURL + data.carID + "_large_1.png"; // adds the rest of the car URL and reassigns it to carURL
      } else {
        carURL = (await nitrotype.NTBOOTSTRAP()).filter(array => array[0] == "CAR_PAINTED_URL")[0][1]; // fetches the car URL that painted cars use ("https://www.nitrotype.com/cars/painted/") and reassigns it to carURL
        carURL = carURL + data.carID + "_large_1_" + data.carHueAngle + ".png"; // adds the rest of the car URL and reassigns it to carURL
      }
      console.log(carURL); // prints the URL to the console
    })
  } catch (error) {
    console.log(error);
  }
}

example();
async function example() {
  const nitrotype = require("nitro-type.js");

  try { // a try-catch statement for error handling
    await nitrotype.bootstrap().then(data => {
      let loot = data.loot; // gets the list of loot
      let resultData = loot.filter(sticker => sticker.name == "Good Race!")[0]; // gets info on the particular sticker
      console.log(resultData); // prints the sticker's data to the console
    })
  } catch (error) {
    console.log(error);
  }
}

example();