https://github.com/gw2efficiency/chat-codes
Encode and decode guildwars2 chat codes
https://github.com/gw2efficiency/chat-codes
maintained npm-package
Last synced: 3 months ago
JSON representation
Encode and decode guildwars2 chat codes
- Host: GitHub
- URL: https://github.com/gw2efficiency/chat-codes
- Owner: gw2efficiency
- License: mit
- Created: 2016-04-08T13:08:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-06T16:01:55.000Z (about 2 years ago)
- Last Synced: 2025-05-25T17:04:28.450Z (4 months ago)
- Topics: maintained, npm-package
- Language: TypeScript
- Size: 193 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# chat-codes
[](https://app.travis-ci.com/github/gw2efficiency/chat-codes)
[](https://codecov.io/github/gw2efficiency/chat-codes)> Encode and decode Guild Wars2 chat codes
*This is part of [gw2efficiency](https://gw2efficiency.com). Please report all issues in [the central repository](https://github.com/gw2efficiency/issues/issues).*
## Install
```
npm install gw2e-chat-codes
```This module can be used for Node.js as well as browsers using [Browserify](https://github.com/substack/browserify-handbook#how-node_modules-works).
## Usage
```js
const { encode, decode } = require('gw2e-chat-codes')// Encode a type and id as a chat code
// Valid types are item, map, skill, trait, recipe, skin, outfit & objective
let encodedSkill = encode('skill', 5842)
// -> '[&BtIWAAA=]'// You can pass an object as second parameter to also encode quantity, skin or upgrades
let encodedItem = encode('item', {id: 46762, quantity: 10, skin: 5807, upgrades: [24554, 24615]})
// -> '[&AgGqtgDgrxYAAOpfAAAnYAAA]'// Decode a chat code into type and id
let decodedCode = decode('[&BtIWAAA=]')
// -> {type: 'skin', id: 5842}
```## Tests
```
npm test
```## Licence
MIT
Big thanks to [codemasher](https://github.com/codemasher) & [poke](https://github.com/poke),
who wrote [this algorithm in PHP](https://gist.github.com/codemasher/47dea40f70f990480c5b), and
[darthmaim](https://github.com/darthmaim) who wrote most of the build template link code.