Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

# Trigger the workflow on push or pull request
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@ typings/
# dotenv environment variables file
.env

# macOS System Files
.DS_Store
.nosync

# Development Environment
.vscode
14 changes: 9 additions & 5 deletions ItemTracked.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ var computeVelocityVector = require('./utils').computeVelocityVector
// Use a simple incremental unique id for the display
var idDisplay = 0;

exports.ItemTracked = function(properties, frameNb, DEFAULT_UNMATCHEDFRAMES_TOLERANCE){
var DEFAULT_UNMATCHEDFRAMES_TOLERANCE = DEFAULT_UNMATCHEDFRAMES_TOLERANCE;
exports.ItemTracked = function(properties, frameNb, unMatchedFramesTolerance, fastDelete){
var DEFAULT_UNMATCHEDFRAMES_TOLERANCE = unMatchedFramesTolerance;
var itemTracked = {};
// ==== Private =====
// Am I available to be matched?
itemTracked.available = true;
// Should I be deleted?
itemTracked.delete = false;
itemTracked.fastDelete = fastDelete;
// How many unmatched frame should I survive?
itemTracked.frameUnmatchedLeftBeforeDying = DEFAULT_UNMATCHEDFRAMES_TOLERANCE;
itemTracked.frameUnmatchedLeftBeforeDying = unMatchedFramesTolerance;
itemTracked.isZombie = false;
itemTracked.appearFrame = frameNb;
itemTracked.disappearFrame = null;
Expand Down Expand Up @@ -98,7 +99,7 @@ exports.ItemTracked = function(properties, frameNb, DEFAULT_UNMATCHEDFRAMES_TOLE
return this;
}
itemTracked.countDown = function(frameNb) {
// Set frame disappear number
// Set frame disappear number
if(this.disappearFrame === null) {
this.disappearFrame = frameNb;
this.disappearArea = {
Expand All @@ -111,7 +112,7 @@ exports.ItemTracked = function(properties, frameNb, DEFAULT_UNMATCHEDFRAMES_TOLE
this.frameUnmatchedLeftBeforeDying--;
this.isZombie = true;
// If it was matched less than 1 time, it should die quick
if(this.nbTimeMatched <= 1) {
if(this.fastDelete && this.nbTimeMatched <= 1) {
this.frameUnmatchedLeftBeforeDying = -1;
}
}
Expand Down Expand Up @@ -212,3 +213,6 @@ exports.ItemTracked = function(properties, frameNb, DEFAULT_UNMATCHEDFRAMES_TOLE
return itemTracked;
};

exports.reset = function() {
idDisplay = 0;
}
Loading