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

@pkmn/anon

v0.1.14

Published

Logic for anonymizing Pokémon Showdown battle simulator logs

Downloads

19

Readme

@pkmn/anon

Test Status License npm version

Logic for anonymizing Pokémon Showdown teams and battle logs.

Installation

$ npm install @pkmn/anon

Usage

@pkmn/anon provides an Anonymizer class which can be used to anonymize teams or battle logs:

import {Anonymizer, Verifier} from '@pkmn/anon';
import {Generations} from '@pkmn/data';
import {Dex} from '@pkmn/dex';

const gens = new Generations(Dex);
const gen = gens.get(raw.format.startsWith('gen') ? +raw.format.charAt(3) : 6);

const verifier = new Verifier();
const anon = Anonymizer.anonymize(gen, raw, {verifier});
if (verifier.ok()) console.log(JSON.stringify(anon, null, 2));

By default, anonymization will replace player's usernames with 'Player 1' and 'Player 2' and Pokémon's nicknames with their species name (in addition to removing chat logs, timestamps, rating info, etc). Both anonymize and anonymizeTeam take a 'salt' option which will cause the Anonymizer to hash the usernames and nicknames with the salt instead - this mode allows for tracking the presence of a player or Pokémon accross multiple battle logs without revealing the true identities.

Anonymizer's methods also take an option 'verifier' parameter - a Verifier can be used to sanity check the log output and ensure no names have leaked out. This is almost always due to a false positive (often a Pokémon being nicknamed something which appears in the output logs in another location), but can be helpful in ensuring no PII gets leaked due to bugs or oversight.

CLI

The anonymize tool takes in a log as input and anonymizes it:

$ anonymize 2020-09/gen8ou/2020-09-25/gen8ou-2875469343.log

If there are potential leaks the warnings from the Verifier will be output instead. For anonymizing logs efficiently en masse, see @pkmn/logs and the smogon/anon workflow. The sample tool can be used to come up with a --formats flag for the workflow - the tool queries past usage stats reports to determine how many battles were present in a given month to be able to determine at what rates to sample at to end up with the desired number of logs for each format:

$ sample 100000 --formats=gen8ou,gen7ou --begin=2022-01 --end=2022-04

This produces --formats=gen8ou:0.019417382834173616,gen7ou:0.00402947392710268.

Browser

The recommended way of using @pkmn/anon in a web browser is to configure your bundler (Webpack, Rollup, Parcel, etc) to minimize it and package it with the rest of your application.

License

This package is distributed under the terms of the MIT License.