Git Product home page Git Product logo

trophyutil's Introduction

TrophyUtil

TrophyUtil is a specialized utility library designed for parsing, modelling, and manipulating core PSNProfiles (PSNP) entities like trophies, games, and game series.

Features

  • Isomorphic, working seamlessly in both frontend and backend (via jsdom) projects.
  • Compatible with both CommonJS and ESM.
  • HTML parsers for core PSNP entities like trophies, games, and game series.
  • Richly-annotated interfaces and classes that provide helpful methods, like transforming a completion time into a timestamp and vice versa.
  • Additional interfaces for MongoDB/Mongoose provide smoother database integration with properties like createdAt and updatedAt.
  • Specialized utility functions for trophy-specific use cases like parsing formatted numbers and checking for relative equality between entities.

Installation

Install TrophyUtil using npm:

npm install trophyutil

Usage

Here's how you might use this library to parse games, for example:

import {getPsnpPageType, PsnpGameStandard, ParserGameStandard} from 'trophyutil';

// Select nodes based on page type
const pageType = getPsnpPageType(window.location);
const gameNodes = PsnpGameStandard.getGameNodes(pageType, window.document);

// Parse nodes into richly-interfaced data
const parser = new ParserGameStandard();
const gameData = gameNodes.map(node => parser.parse(node));
const speed = gameData[0].completionSpeed; // 3661

// Classes wrap data with utility methods
const games = gameData.map(data => new PsnpGameStandard(data));
const speedString = PsnpGameStandard.secondsToSpeedString(speed); // "1 hour, 1 minute"

Contributing

Contributions are welcome! Submit a pull request or create an issue to contribute to this project.

License

This project is licensed under the GPLv3 License - see COPYING.txt for details.

trophyutil's People

Contributors

gionascm2 avatar

Stargazers

The Savior avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.