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

pnw4js

v1.0.6

Published

A super simple npm library for interacting with Politics and War via JavaScript.

Downloads

12

Readme

pnw4js

pnw4js is a simple, type safe, promise-based JavaScript library for accessing the Politics & War API. It is written in TypeScript for CommonJS, NodeJS and TypeScript. Compiles to ES5.

Features

Why use pnw4js?

  • Extremely Simple To Install, Setup and Use
  • Clear, Extensive Documentation
  • Constant Support
  • Async, promise-based
  • Type Safe
  • Only JavaScript library for PnW

Installation

The easiest way to install pnw4js is using npm in your project directory.

cd project_dir
npm install pnw4js

For greater flexibility — such as the ability to edit the code or manually configure the APIs — you are able to manually clone the project from the github. In your project directory, you will want to clone the Git repository. Note that you can still make changes to an npm installation of pnw4js, at the risk of it being lost in an update.

cd project_dir
git clone https://github.com/dkantereivin/pnw4js # Project from Github
npm install # Installs all dependencies
npm install typescript # for compiling github project
tsc

You will then see a dist folder which contains .js files. Copy the entire contents of the folder into your project folder. To edit the files, you should perform any edits in .ts source files and then recompile using tsc.

Usage

For standard installation using npm, the following code outlines usage.

NodeJS:
const PoliticsAndWar = require("pnw4js");
let pnw = new PoliticsAndWar("key", "password");

let nationCall = await pnw.nation(64060); // test call
CommonJS/TypeScript:
import PoliticsAndWar from "pnw4js";
let pnw = new PoliticsAndWar("key", "password");

let nationCall = await pnw.nation(64060);

This library is compatible with TypeScript. Please see Documentation for in-depth documentation. The PoliticsAndWar(key, [pass]) constructor requires a string parameter for the key, and the default password is pnw. The password is readonly, however key can be updated using the setKey(key) method.

Documentation & Support

In order to promote ease of use and accessibility, this library is straightforward and documented on Github Pages written and generated using TSDoc.

Please click here to view generated documentation. Alternatively, just read through source code, type annotations and inline documentation.

Support

This library is actively supported and developed by the creator. Feel free to post an issue on the page, or contact me on Discord @Canter#0548 (send a friend request). You can also join the my Discord and ping me.

Testing & Updates

This library has been tested and deployed in NodeJS and browser environments. That being said, there likely exist undiscovered bugs. Please submit an issue request if you encounter any problems using the library.

This is current Version 1 of pnw4js. Future versions are likely to include:

  • addition of POST functions (i.e. send message, send alliance bank resources/money); approved by Alex
  • caching of recent calls; either based on expiry time, cache memory size, or number of cached records
  • support for the game's APIv2, when it is released
  • creating an exposed "raw" api function, and a function to call an api by string (for convenience)
  • filtering of API calls on top of those provided by the API, and analysis of results
  • compatability with Google Sheets using Babel and clasp (unlikely, if you want this, please contact me)
  • Wiki and better documentation (on Github)

Any code written using current project versions will continue to be supported in future versions.

New in v1.0.6

  • added missing wars and warAttacks api, contributed by luketp
  • updated README: corrected future plans and installation instructions
  • distribution code being run by JavaScript is now optimized and minified using the Closure Compiler
  • documentation removed from npm package to reduce size
  • minor miscellaneous changes to functions.ts
  • updated all dependencies to latest versions

Contributing

As an open-source project, any pull requests are welcome! If you implement the library and create any major features, please feel free to send me a message if you're unsure on how to implement them into the library.

Pull requests are welcome. Please include a description of each commit, and keep your contributions atomic - one major feature per pull request please!

License

MIT