@markw65/monkeyc-optimizer 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/util.cjs CHANGED
@@ -4093,19 +4093,29 @@ function readByLine(file, lineHandler) {
4093
4093
  );
4094
4094
  }
4095
4095
 
4096
- async function promiseAll(promises, parallelism) {
4096
+ async function promiseAll(promiseFn, parallelism) {
4097
4097
  parallelism = parallelism || 4;
4098
4098
  const serializer = [];
4099
4099
  const results = [];
4100
- const capture = (r, i) => (results[i] = r);
4101
- promises.forEach((p, i) => {
4102
- const cap = () => p.then((r) => capture(r, i));
4103
- if (serializer.length < parallelism) {
4104
- serializer.push(cap());
4105
- } else {
4106
- serializer[i % parallelism] = serializer[i % parallelism].then(cap);
4100
+ let done = false;
4101
+ let i = 0;
4102
+ const next = () => {
4103
+ const index = i++;
4104
+ if (done) return;
4105
+ const promise = promiseFn(index);
4106
+ if (!promise) {
4107
+ done = true;
4108
+ return;
4107
4109
  }
4108
- });
4110
+ return promise
4111
+ .then((r) => {
4112
+ results[index] = r;
4113
+ })
4114
+ .then(next);
4115
+ };
4116
+ while (i < parallelism) {
4117
+ serializer.push(next());
4118
+ }
4109
4119
  return Promise.all(serializer).then(() => results);
4110
4120
  }
4111
4121
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "module",
4
- "version": "1.0.8",
4
+ "version": "1.0.9",
5
5
  "description": "Source to source optimizer for Garmin Monkey C code",
6
6
  "main": "build/optimizer.cjs",
7
7
  "exports": {
@@ -19,12 +19,13 @@
19
19
  "files": [
20
20
  "build/optimizer.cjs",
21
21
  "build/util.cjs",
22
+ "build/sdk-util.cjs",
22
23
  "build/api.cjs"
23
24
  ],
24
25
  "author": "markw65",
25
26
  "license": "MIT",
26
27
  "dependencies": {
27
- "@markw65/prettier-plugin-monkeyc": "^1.0.14"
28
+ "@markw65/prettier-plugin-monkeyc": "^1.0.15"
28
29
  },
29
30
  "devDependencies": {
30
31
  "eslint": "^8.12.0",