Skip to content

Commit

Permalink
Merge pull request #380 from atesgoral/atesgoral/update-outbox-generator
Browse files Browse the repository at this point in the history
Update hrm-level-outbox-generator and remove local patches
  • Loading branch information
atesgoral authored Jul 6, 2024
2 parents cbba3a7 + 2e31112 commit 6c7b042
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 63 deletions.
59 changes: 1 addition & 58 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,61 +127,6 @@ function inspect() {
});
}

/** Temp patches until the package is fixed and updated */
function splitGroups(arr, groupSize) {
var strings = [],
zeroPos;

for (var i = 0; i < arr.length; i += groupSize) {
strings.push(arr.slice(i, i + groupSize));
}

return strings;
}

function splitStrings(arr) {
var strings = [],
zeroPos;

while (arr.length) {
zeroPos = arr.indexOf(0);
strings.push(arr.slice(0, zeroPos));
arr = arr.slice(zeroPos + 1);
}

return strings;
}

const outboxGeneratorPatches = {
4: function (inbox) {
// Output each pair with the items in reverse order
return splitGroups(inbox, 2).reduce(function (outbox, pair) {
return outbox.concat(pair.reverse());
}, []);
},
28: function (inbox) {
// For each triple, sort then output
return splitGroups(inbox, 3).reduce(function (outbox, triplet) {
return outbox.concat(triplet.sort((a, b) => a - b));
}, []);
},
41: function (inbox) {
// Split strings, sort items in each string, then output all strings
return splitStrings(inbox)
.map(function (string) {
return string
.map((n) => parseInt(n, 36))
.sort((a, b) => a - b)
.map((n) => n.toString(36).toUpperCase());
})
.reduce(function (output, string) {
return output.concat(string);
});
},
};

/** End of temp patches */

function benchmark() {
return plugins.tap((file) => {
try {
Expand All @@ -193,9 +138,7 @@ function benchmark() {

while (runs.length < 100) {
const inbox = inboxGenerator.generate(data.level.number);
const outbox = outboxGeneratorPatches[data.level.number]
? outboxGeneratorPatches[data.level.number](inbox)
: outboxGenerator.generate(data.level.number, inbox);
const outbox = outboxGenerator.generate(data.level.number, inbox);

runs.push({
inbox,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"hrm-cpu": "^0.2.3",
"hrm-level-data": "^1.1.2",
"hrm-level-inbox-generator": "0.0.4",
"hrm-level-outbox-generator": "0.0.2",
"hrm-level-outbox-generator": "^1.0.0",
"hrm-parser": "^0.2.2",
"marked": "^5.0.0",
"md5": "^2.3.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1808,10 +1808,10 @@ hrm-level-inbox-generator@0.0.4:
hrm-level-data "^1.0.0"
mersenne-twister "^1.0.1"

hrm-level-outbox-generator@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/hrm-level-outbox-generator/-/hrm-level-outbox-generator-0.0.2.tgz#017dcde92ce5e8cbcc7e8cbc533540be88429610"
integrity sha512-6Ev8EpD5qzrkaOHoyel/9i9eAFfEWacT8GCYM5LGgtFRbWmKvwFE8oxxQ3L0iDNrJmoqWQuqqYN09h/j5bo+1w==
hrm-level-outbox-generator@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/hrm-level-outbox-generator/-/hrm-level-outbox-generator-1.0.0.tgz#f0f652e8fcd7620529deaf9138b65cc6702911c6"
integrity sha512-608eOCzWIMPbVf8z5RqwjsfnEieUJgZdun6LtiEdE6UBxGwWULYx/zGCWYSOhj50G4yjorqH8h5nBezGj3q0Jw==
dependencies:
hrm-level-data "^1.1.0"
quick-primefactors "^1.0.0"
Expand Down

0 comments on commit 6c7b042

Please sign in to comment.