0.3.0 • Published 3 years ago

@jettalibs/stacking-weight-restriction v0.3.0

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
3 years ago

Stacking Weight Restriction

This repository came to life due to a demand of the Blocks Generation Algorithm. Occasionally, this restriction algorithm became somewhat big and was demanded somewhere else. Creating this repository was a natural evolution.

This repository implements the restriction of the allowed weight of a stack on an item. Said in another words: an item cannot have too much weight on it, otherwise it is damaged. The algorithm here implemented checks whether that situation occurs or not.

npm.io

Install Dependencies

This project is implemented using Node.js . npm is used for managing dependencies and meta data.

You can install all dependencies executing:

npm install .

Usage

This project is intended to be used by the Blocks Generation Algorithm. It implements an object with a check method. In order to use it, you add to your JavaScript code something like:

stacking_weight_restriction = require("stacking-weight-restriction");

restriction = new stacking_weight_restriction.StackingWeightRestriction();
restriction.check(items);

Usage in Blocks Generation Algorithm

The Blocks Generation Algorithm doesn't use the interface +check(items: Array<Item>): bool, it uses +check(block, container): bool so a connector must be implemented in order to make everything compatible.

Something like:

const stacking_weight_restriction_connector = function(block, container) {
    return block.context.items.concat(container.items);
}

should be enough to solve the problem.

Testing

For testing, the Mocha Framework is used in combination with Chai Assertion Library.

The tests are located in the folder src/test/. The data used in the tests are JSON files located in the folder src/test/data/.

You can run all the tests executing:

npm test

Code Coverage

This repository tries to keep tested all the developed code. You can check test coverage executing:

npm run coverage

Two reports will be created (see the figures below).

  1. coverage/index.html. Open it with any internet browser (firefox, chrome, ...) and check a detailed description of the code coverage.
  2. A summary report will be displayed on the command line.

Getting Help

This project was mainly developed by Lucas Guesser lucas@jettacargo.com.br, who you can contact in case you need any help.

Git Commit Messages

The commit messages must be written according to Conventional Commits.

Additionally, follow the rules provided in How to Write a Git Commit Message and Angular commit message guidelines.

Acknowledgment

Special thanks to Luiz luiz@jettacargo.com.br, Jean jean@jettacargo.com.br, and Caroline caroline@jettacargo.com.br who contributed very much with discussions and insights for the development and implementation of the algorithm.

0.3.0

3 years ago

0.1.0

3 years ago

0.2.0

3 years ago