Skip to content

Commit

Permalink
Dependency Updates (#1)
Browse files Browse the repository at this point in the history
* dependency updates
* use github actions for tests
  • Loading branch information
farskipper committed Nov 12, 2023
1 parent 6f99310 commit c21fb5d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 17 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test
on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
node:
- lts/*
- current
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v3
- name: Node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# select-when

[![Build Status](https://travis-ci.org/Picolab/select-when.svg)](https://travis-ci.org/Picolab/select-when)
[![Build Status](https://github.com/Picolab/select-when/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/Picolab/select-when/actions/workflows/test.yml)

This javascript library makes it _easy_ to create rules that **pattern match** on event streams.

Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,27 @@
"scripts": {
"prepublish": "npm run build",
"build": "rm -rf dist && tsc",
"test": "ava --reset-cache && ava"
"test": "ava reset-cache && ava"
},
"devDependencies": {
"@types/lodash": "^4.14.136",
"ava": "^2.2.0",
"ts-node": "^8.3.0",
"typescript": "^3.5.2"
"ava": "^5.3.1",
"ts-node": "^10.4.0",
"typescript": "^5.2.2"
},
"dependencies": {
"lodash": "^4.17.11"
},
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
],
"files": [
"test/**/*",
"!test/helpers/**/*"
]
}
}
9 changes: 4 additions & 5 deletions src/StateMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
TransitionCompact,
TransitionEvent_event,
TransitionEvent,
Saliance,
StateShape
Saliance
} from "./types";

function genState() {
Expand Down Expand Up @@ -268,13 +267,13 @@ export class StateMachine<DataT, StateT> {
}
}

async function stmMatcher<DataT, StateT extends StateShape>(
async function stmMatcher<DataT, StateT>(
stm: CompiledStateMachine,
event: Event<DataT>,
state: StateT | null | undefined
): Promise<MatcherRet<StateT>> {
let stateStates: string[] =
state && _.isArray(state.states) ? state.states : [];
state && _.isArray((state as any).states) ? (state as any).states : [];
let stmStates = stateStates.filter(st => _.has(stm, st));

if (stmStates.length === 0) {
Expand Down Expand Up @@ -313,7 +312,7 @@ async function stmMatcher<DataT, StateT extends StateShape>(
};
}

async function evalExpr<DataT, StateT extends StateShape>(
async function evalExpr<DataT, StateT>(
expr: TransitionEvent<DataT, StateT>,
event: Event<DataT>,
state: StateT | null | undefined
Expand Down
2 changes: 1 addition & 1 deletion src/expressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export function within<DataT, StateT extends WithinStateShape>(
let tlimit = await tlimitFn(event, state);

let stmStates = _.filter(
_.flattenDeep([state && state.states]),
_.flattenDeep<string | null | undefined>([state && state.states]),
_.isString
);
if (timeSinceLast > tlimit) {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"outDir": "dist",
"strict": true
},
"include": ["src"]
"include": ["src/**/*", "test/**/*"],
"exclude": ["node_modules", "**/node_modules/*"]
}

0 comments on commit c21fb5d

Please sign in to comment.