Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
implement deferred component and entity removal. renamed emptyListene…
…rs to cleanup. fixes #6
- Loading branch information
Mike Reinstein
committed
Jul 4, 2020
1 parent
e548521
commit 9f8d970
Showing
8 changed files
with
139 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// insert the new item such that the array stays ordered from highest to lowest | ||
export default function orderedInsert (arr, val) { | ||
for (let i=0; i < arr.length; i++) { | ||
if (arr[i] <= val) { | ||
arr.splice(i, 0, val) | ||
return | ||
} | ||
} | ||
|
||
arr.push(val) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,9 @@ tap.same(w, { | |
listeners: { | ||
added: { }, | ||
removed: { } | ||
}, | ||
removals: { | ||
entities: [ ], | ||
components: [ ] | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import orderedInsert from '../ordered-insert.js' | ||
import tap from 'tap' | ||
|
||
|
||
function randomInt (min, max) { | ||
const d = max - min | ||
return min + Math.floor(d * Math.random()) | ||
} | ||
|
||
|
||
const a = [ ] | ||
|
||
|
||
for (let i=0; i < 10; i++) { | ||
const val = randomInt(1, 100) | ||
orderedInsert(a, val) | ||
} | ||
|
||
|
||
let last = a[0] | ||
for (let i=1; i < a.length; i++) { | ||
tap.assert(last >= a[i], 'sorts highest to lowest') | ||
last = a[i] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters