Skip to content

Commit

Permalink
Merge pull request #45 from nut-tree/develop
Browse files Browse the repository at this point in the history
Release v0.1.0-beta.1
  • Loading branch information
s1hofmann authored Mar 11, 2019
2 parents 6902b01 + 9863e44 commit 823e1cd
Show file tree
Hide file tree
Showing 10 changed files with 1,230 additions and 1,149 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,11 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Test data
/lib/provider/opencv/__mocks__/output.jpg
/asdf.jpg
/foo_asdf_bar.jpg
/asdf.png
/asdf_bar.jpg
/foo_asdf.jpg
7 changes: 6 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ tslint.json
.vscode
.idea
.github
/.gfx
/.gfx
/asdf.jpg
/foo_asdf_bar.jpg
/asdf.png
/asdf_bar.jpg
/foo_asdf.jpg
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# nut.js change log

All notable changes to this project will be documented in this file.


## 0.1.0-beta.1

- Enabled pre-built OpenCV bindings via `opencv4nodejs-prebuilt`
18 changes: 10 additions & 8 deletions lib/keyboard.class.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { NativeAdapter } from "./adapter/native.adapter.class";
import { Key } from "./key.enum";

export class Keyboard {
type StringOrKey = string[] | Key[];

private static inputIsString(input: string[] | Key[]): boolean {
return input.every((elem: string | Key) => typeof elem === "string");
}
const inputIsString = (input: string[] | Key[]): input is string[] => {
return input.every((elem: string | Key) => typeof elem === "string");
};

export class Keyboard {

public config = {
autoDelayMs: 500,
Expand All @@ -18,11 +20,11 @@ export class Keyboard {
this.lastAction = Date.now();
}

public type(...input: string[] | Key[]): Promise<Keyboard> {
public type(...input: StringOrKey): Promise<Keyboard> {
return new Promise<Keyboard>(async resolve => {
if (Keyboard.inputIsString(input)) {
if (inputIsString(input)) {
for (const char of input.join(" ").split("")) {
await this.waitForNextTick();
await this.nextTick();
this.nativeAdapter.type(char);
this.updateTick();
}
Expand Down Expand Up @@ -51,7 +53,7 @@ export class Keyboard {
this.lastAction = Date.now();
}

private async waitForNextTick(): Promise<void> {
private async nextTick(): Promise<void> {
return new Promise<void>(resolve => {
let current = Date.now();
while (current - this.lastAction < this.config.autoDelayMs) {
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/opencv/image-processor.class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as cv from "opencv4nodejs";
import * as cv from "opencv4nodejs-prebuilt";
import { Image } from "../../image.class";
import { Region } from "../../region.class";

Expand Down
2 changes: 1 addition & 1 deletion lib/provider/opencv/image-reader.class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as cv from "opencv4nodejs";
import * as cv from "opencv4nodejs-prebuilt";
import { Image } from "../../image.class";
import { DataSource } from "./data-source.interface";

Expand Down
2 changes: 1 addition & 1 deletion lib/provider/opencv/image-writer.class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as cv from "opencv4nodejs";
import * as cv from "opencv4nodejs-prebuilt";
import { Image } from "../../image.class";
import { DataSink } from "./data-sink.interface";
import { ImageProcessor } from "./image-processor.class";
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/opencv/template-matching-finder.class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as cv from "opencv4nodejs";
import * as cv from "opencv4nodejs-prebuilt";
import * as path from "path";
import { Image } from "../../image.class";
import { MatchRequest } from "../../match-request.class";
Expand Down
Loading

0 comments on commit 823e1cd

Please sign in to comment.