7.6.0 • Published 3 months ago

trophyutil v7.6.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
3 months ago

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.

7.6.0

3 months ago

7.4.0

11 months ago

7.3.1

12 months ago

7.3.0

12 months ago

7.4.4

11 months ago

7.4.3

11 months ago

7.5.1

10 months ago

7.4.2

11 months ago

7.5.0

11 months ago

7.4.1

11 months ago

7.3.2

12 months ago

7.2.4

12 months ago

7.2.3

12 months ago

7.2.2

12 months ago

7.2.1

12 months ago

7.2.0

1 year ago

7.1.3

1 year ago

7.1.2

1 year ago

7.1.1

1 year ago

7.1.0

1 year ago

7.0.0

1 year ago

6.0.5

1 year ago

6.0.4

1 year ago

6.0.3

1 year ago