JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q42925F
  • License MIT

Get a League of Legends champion from their key.

Package Exports

  • champion

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (champion) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

champion

Get a League of Legends champion from their key.

Build Status Testling Badge

Example

var champion = require('champion');

champion(117, function(error, champ) {
  if (error) throw error;

  console.log(champ);
});

Installation

$ npm install champion

Browserify for the browser.

API

champion(key, callback)

Look up a champion using a Number key and call callback(error, champ) where champ is an Object.

The array

Yeah, it's huge, but the current method is better than using fs or http.

If a new champion hasn't been added to the array yet, feel free to open a pull request. In the future, I might move the array to its own module so that others can use it in their modules.

Lessons learned

Originally, this module used fs.createReadStream in order to load a JSON file of champions. This ReadStrean was then piped to JSONStream, but this caused problems because of a known issue involving precise numbers (which are used for a champion's health regeneration and such).

Using fs also prevented this module from working in the browser. So, I did a quick refactor and replaced the JSON file with a JavaScript one. This JavaScript file exports the array of champions and as such can be require()d and browserified.