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

@v0rt4c/otb

v0.1.0

Published

This library reads and writes Open Tibia .OTB files.

Downloads

2

Readme

@v0rt4c/ot-otb

This library reads and writes Open Tibia .OTB files.

Table of contents

Getting Started

The library supports multiple platforms (Browser, NodeJS and Deno).

NodeJS

CommonJS

const { OTBReader, OTBWriter } = require('@v0rt4c/ot-otb');

ES6

import { OTBReader, OTBWriter } from '@v0rt4c/ot-otb';

Deno

import { OTBReader, OTBWriter } from 'https://deno.land/x/[email protected]/mod.ts';

Usage

Reading .OTB

Reading the .OTB file is really easy. Simply create a new instance of the OTBReader and provide it with the .OTB file buffer. The buffer param must be a Uint8Array. Then call the parse method to get the RootNode.

const reader = new OTBReader(otbBuffer);
const rootNode = reader.parse();

console.log(rootNode);

Output

RootNode {
  _itemsMajorVersion: 1,
  _itemsMinorVersion: 3,
  _itemsBuildNumber: 17,
  _children: [Item, Item, Item, Item, ..., ...]
  }

Writing .OTB

Writing the .OTB file back to its original form is also really easy. Simply create a new instance of the OTBWriter and provide it with the RootNode. Then call the writeBuffer method. This will give you the .OTB buffer back as the return value.

const writer = new OTBWriter(rootNode);
const buffer = writer.writeBuffer();

API

RootNode

The RootNode class holds information about the .OTB file such as the versions & buildnumber. It also holds all the items in the .OTB file in an array.

Constructor

| @Params | Optional | |-------------------|----------| | itemsMajorVersion | false | | itemsMinorVersion | false | | itemsBuildVersion | false |

Properties

| Property | Getter | Setter | |-------------------|--------|--------| | itemsMajorVersion | X | X | | itemsMinorVersion | X | X | | itemsBuildNumber | X | X | | children | X | |

Methods

| Method | Params | Description | |----------------------|-------------------|-------------------------------------------------| | addItem | item : Item | Adds a new item to the root node | | getItemByServerId | serverId : number | Gets a specific item by its server ID | | getItemByClientId | clientId : number | Gets a specific item by its client ID | | removeItemByServerId | serverId : number | Removes an item by providing its server ID | | removeItemByClientId | clientId : number | Removes an item by providing its client ID | | popItem | | Removes an item from the end of the item list | | shiftItem | | Removes an item from the start of the item list |

Item

The Item class holds information about an item, such as the server ID, client ID, flags & attributes.

Constructor

The Item constructor takes no arguments.

Properties

| Property | Getter | Setter | |------------|--------|--------| | serverId | X | X | | clientId | X | X | | type | X | X | | group | X | X | | flags | X | | | attributes | X | |

Methods

| Method | Params | Description | |------------------|---------------------------------|-------------------------------------------------| | setAttribute | attribute : string, value : any | Sets an attribute on the item | | setFlags | flags : number | Sets the item flags from the provided integer | | setFlag | flag : string, value : boolean | Sets a specific flag | | getFlagsInt | | Returns the integer value for the item flags |

Authors

V0RT4C

License

MIT License