Deps galore

master
Kuba Orlik 3 years ago
parent 04a4fa2953
commit e24cc50bc3

55
package-lock.json generated

@ -9,9 +9,10 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"abortable-promise": "git+https://git.kuba-orlik.name/kuba/abortable-promises.git#ee3d998",
"async-spawner": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#7ee6a21",
"abortable-gen-promises": "^0.1.0",
"async-spawner": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#a3d1a2b",
"emittery": "^0.8.1",
"perspective-shift": "git+https://git.kuba-orlik.name/kuba/perspective-shift.git#f4769d3",
"tempy": "^1.0.1"
},
"devDependencies": {
@ -51,15 +52,15 @@
}
},
"node_modules/@types/node": {
"version": "14.14.35",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.35.tgz",
"integrity": "sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag=="
"version": "14.14.37",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz",
"integrity": "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw=="
},
"node_modules/abortable-promise": {
"node_modules/abortable-gen-promises": {
"version": "0.1.0",
"resolved": "git+https://git.kuba-orlik.name/kuba/abortable-promises.git#ee3d998c08b43a2efb15d921f592e8fdc433f487",
"resolved": "https://registry.npmjs.org/abortable-gen-promises/-/abortable-gen-promises-0.1.0.tgz",
"integrity": "sha512-DGEempJ6OYZiDmupX17AsSP6iVNe8fFS8UIolETKquW0muDCgreqMgpk8xnHPxV6dSHpGzGYi2jKGXgcf99leA==",
"hasInstallScript": true,
"license": "ISC",
"dependencies": {
"@types/node": "^14.14.19",
"emittery": "^0.8.1"
@ -87,7 +88,7 @@
},
"node_modules/async-spawner": {
"version": "0.1.7",
"resolved": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#7ee6a21f38834b0a40f75a190e1bbfd0a2b01ead",
"resolved": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#a3d1a2bc27a345263db870dd7e7c3494307d857c",
"hasInstallScript": true,
"license": "ISC",
"dependencies": {
@ -428,6 +429,16 @@
"node": ">=8"
}
},
"node_modules/perspective-shift": {
"version": "0.1.0",
"resolved": "git+https://git.kuba-orlik.name/kuba/perspective-shift.git#f4769d3eb045ddff1454916d8843f034ef286c61",
"license": "ISC",
"dependencies": {
"abortable-gen-promises": "^0.1.0",
"async-spawner": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#a3d1a2bc27a3",
"tempy": "^1.0.1"
}
},
"node_modules/picomatch": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
@ -614,13 +625,14 @@
}
},
"@types/node": {
"version": "14.14.35",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.35.tgz",
"integrity": "sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag=="
"version": "14.14.37",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz",
"integrity": "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw=="
},
"abortable-promise": {
"version": "git+https://git.kuba-orlik.name/kuba/abortable-promises.git#ee3d998c08b43a2efb15d921f592e8fdc433f487",
"from": "abortable-promise@git+https://git.kuba-orlik.name/kuba/abortable-promises.git#ee3d998",
"abortable-gen-promises": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/abortable-gen-promises/-/abortable-gen-promises-0.1.0.tgz",
"integrity": "sha512-DGEempJ6OYZiDmupX17AsSP6iVNe8fFS8UIolETKquW0muDCgreqMgpk8xnHPxV6dSHpGzGYi2jKGXgcf99leA==",
"requires": {
"@types/node": "^14.14.19",
"emittery": "^0.8.1"
@ -641,8 +653,8 @@
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="
},
"async-spawner": {
"version": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#7ee6a21f38834b0a40f75a190e1bbfd0a2b01ead",
"from": "async-spawner@git+https://git.kuba-orlik.name/kuba/async-spawner.git#7ee6a21",
"version": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#a3d1a2bc27a345263db870dd7e7c3494307d857c",
"from": "async-spawner@git+https://git.kuba-orlik.name/kuba/async-spawner.git#a3d1a2b",
"requires": {
"@types/node": "^14.14.19",
"emittery": "^0.8.0"
@ -891,6 +903,15 @@
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw=="
},
"perspective-shift": {
"version": "git+https://git.kuba-orlik.name/kuba/perspective-shift.git#f4769d3eb045ddff1454916d8843f034ef286c61",
"from": "perspective-shift@git+https://git.kuba-orlik.name/kuba/perspective-shift.git#f4769d3",
"requires": {
"abortable-gen-promises": "^0.1.0",
"async-spawner": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#a3d1a2bc27a3",
"tempy": "^1.0.1"
}
},
"picomatch": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",

@ -10,9 +10,10 @@
"author": "",
"license": "ISC",
"dependencies": {
"abortable-promise": "git+https://git.kuba-orlik.name/kuba/abortable-promises.git#4a316bb",
"async-spawner": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#cdbb47d",
"abortable-gen-promises": "^0.1.0",
"async-spawner": "git+https://git.kuba-orlik.name/kuba/async-spawner.git#a3d1a2b",
"emittery": "^0.8.1",
"perspective-shift": "git+https://git.kuba-orlik.name/kuba/perspective-shift.git#f4769d3",
"tempy": "^1.0.1"
},
"devDependencies": {

@ -1,96 +0,0 @@
import { deferedSpawn } from "async-spawner";
import Emittery from "emittery";
import { promisify } from "util";
//needed to pass information on wether or not the promise has been aborted witout 'this'
class AbortableEmittery extends Emittery {
public aborted = false;
abort() {
this.aborted = true;
this.emit("abort");
}
}
class AbortablePromise<T> extends Promise<T | null> {
private emitter: AbortableEmittery;
constructor(
make_generator: (
await_or_abort: (
promise: Promise<any>,
on_abort: () => void
) => Promise<void>
) => AsyncGenerator
) {
const emitter = new AbortableEmittery();
const await_or_abort = (
promise: Promise<any>,
on_abort: () => void
) => {
return new Promise((resolve, reject) => {
let resolved = false;
emitter.on("abort", () => {
if (!resolved) {
on_abort();
resolve(null);
resolved = true;
}
});
promise
.then((result) => {
if (!resolved) {
resolve(result);
resolved = true;
}
})
.catch(reject);
});
};
super(async (resolve, reject) => {
let step_value;
const generator = make_generator(await_or_abort);
do {
if (emitter.aborted) {
resolve(null);
return;
}
step_value = await generator.next();
} while (!step_value.done);
});
this.emitter = emitter;
}
abort() {
this.emitter.abort();
}
}
// const sleep = promisify((timeout: number, callback: (...args: any[]) => void) =>
// setTimeout(callback, timeout)
// );
// const a = new AbortablePromise(async function* () {
// yield await sleep(1000);
// console.log("awaited 100");
// yield await sleep(2000);
// console.log("awaited 200");
// yield await sleep(3000);
// console.log("awaited 300");
// });
// setTimeout(() => a.abort(), 1500);
const b = new AbortablePromise(async function* (await_or_abort) {
const ping = await deferedSpawn("ping", ["8.8.8.8"]);
while (true) {
console.log(
await await_or_abort(ping.waitForNextData(), () => {
ping.kill();
})
);
yield;
}
});
setTimeout(() => b.abort(), 5000);

@ -1,4 +1,4 @@
import AbortablePromise from "abortable-promise";
import AbortablePromise from "abortable-gen-promises";
import { deferedSpawn } from "async-spawner";
import tempy from "tempy";
import {
@ -7,30 +7,31 @@ import {
transformDesc,
transforms,
} from "./transforms";
import perspectiveShift from "perspective-shift";
function perspectiveShift(
input: string,
shift: transformCoefs
): AbortablePromise<string> {
return new AbortablePromise(async function* (await_or_abort) {
const output = tempy.file({ extension: "jpg" });
const args = [
"-verbose",
input,
"-virtual-pixel",
"Transparent",
"-distort",
"PerspectiveProjection",
shift.join(","),
output,
];
const def = await deferedSpawn("convert", args);
const next_data_promise = def.waitForNextData();
yield;
await await_or_abort(next_data_promise, () => def.kill());
return output;
});
}
// function perspectiveShift(
// input: string,
// shift: transformCoefs
// ): AbortablePromise<string> {
// return new AbortablePromise(async function* (await_or_abort) {
// const output = tempy.file({ extension: "jpg" });
// const args = [
// "-verbose",
// input,
// "-virtual-pixel",
// "Transparent",
// "-distort",
// "PerspectiveProjection",
// shift.join(","),
// output,
// ];
// const def = await deferedSpawn("convert", args);
// const next_data_promise = def.waitForNextData();
// yield;
// await await_or_abort(next_data_promise, () => def.kill());
// return output;
// });
// }
type coordinates = { x: number; y: number };
type alpr_candidate = {

@ -1,7 +1,7 @@
import simpleSpawn, { deferedSpawn } from "async-spawner";
import { promises as fs } from "fs";
import path from "path";
import AbortablePromise from "../../abortable-promise/@types";
import AbortablePromise from "abortable-gen-promises";
import { alprMultiPersp, alpr_response } from "./alpr";
async function run(): Promise<void> {

Loading…
Cancel
Save