Skip to content

Commit

Permalink
feat: testing as linb
Browse files Browse the repository at this point in the history
  • Loading branch information
kenerwin88 committed Jan 10, 2023
1 parent d599347 commit 136fab9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
1 change: 0 additions & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const project = new typescript.TypeScriptProject({
copyrightOwner: 'Yarn Community',
projenrcTs: true,
deps: ['@babel/preset-env'],
entrypoint: 'dist/yarn-bound.js',
description: 'Quality of life wrapper around bondage.js',
devDeps: ['eslint-plugin-prettier', 'esbuild', 'prettier', 'eslint-plugin-sonarjs', 'ts-node'],
tsconfig: {
Expand Down
4 changes: 2 additions & 2 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 27 additions & 6 deletions src/yarn-bound.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
// @ts-nocheck
import bondage from './bondage';
import parseLine from './line-parser';


interface props {
dialogue: string;
variableStorage: any;
functions: any;
handleCommand: any;
combineTextAndOptionsResults: any;
locale: any;
startAt: string;
}

export default class YarnBound {
public handleCommand: any;
public combineTextAndOptionsResults: any;
public bondage: any;
public bufferedNode: any;
public currentResult: any;
public history: any;
public locale: any;
public runner: any;
private generator: any;

constructor({
dialogue,
variableStorage,
functions,
handleCommand,
combineTextAndOptionsResults,
locale,
locale = undefined,
startAt = 'Start',
}) {
}: props) {
this.handleCommand = handleCommand;
this.combineTextAndOptionsResults = combineTextAndOptionsResults;
this.bondage = bondage;
Expand All @@ -37,14 +57,14 @@ export default class YarnBound {
this.jump(startAt);
}

jump(startAt) {
jump(startAt: string) {
this.generator = this.runner.run(startAt);
this.bufferedNode = null;
this.advance();
}

// eslint-disable-next-line sonarjs/cognitive-complexity
advance(optionIndex: number) {
advance(optionIndex: undefined | number = undefined) {
if (typeof optionIndex !== 'undefined' && this.currentResult && this.currentResult.select) {
this.currentResult.select(optionIndex);
}
Expand Down Expand Up @@ -85,6 +105,7 @@ export default class YarnBound {
if (next instanceof bondage.TextResult) {
parseLine(next, this.locale);
} else if (next instanceof bondage.OptionsResult) {
// @ts-ignore
if (next.text) {
parseLine(next, this.locale);
}
Expand All @@ -97,7 +118,7 @@ export default class YarnBound {
this.bufferedNode = buffered;
}

registerFunction(name: string, func) {
registerFunction(name: string, func: any) {
this.runner.registerFunction(name, func);
}
}

0 comments on commit 136fab9

Please sign in to comment.