Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fauton

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fauton - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

dist/libs/FiniteAutomataTest.d.ts

@@ -8,2 +8,4 @@ import { DeterministicFiniteAutomaton } from './DeterministicFiniteAutomaton';

aggregate: boolean;
accepted: boolean;
rejected: boolean;
}

@@ -10,0 +12,0 @@ declare type IOption = {

@@ -44,2 +44,8 @@ "use strict";

: null,
acceptedWriteStream: outputFiles.correct
? fs_1.default.createWriteStream(path_1.default.resolve(this.#logsPath, `${automatonLabel}.accepted.txt`))
: null,
rejectedWriteStream: outputFiles.input
? fs_1.default.createWriteStream(path_1.default.resolve(this.#logsPath, `${automatonLabel}.rejected.txt`))
: null,
};

@@ -58,3 +64,3 @@ return {

#testAutomata(finiteAutomaton, finiteAutomatonTestInfo, writeStreams, inputStrings) {
const { caseWriteStream, correctWriteStream, incorrectWriteStream, inputWriteStream } = writeStreams;
const { caseWriteStream, correctWriteStream, acceptedWriteStream, rejectedWriteStream, incorrectWriteStream, inputWriteStream, } = writeStreams;
for (let i = 0; i < inputStrings.length; i++) {

@@ -73,2 +79,8 @@ const inputString = inputStrings[i].replace('\r', '').replace('\n', '');

'\n';
if (!automatonTestResult) {
rejectedWriteStream && rejectedWriteStream.write(inputString + '\n');
}
else {
acceptedWriteStream && acceptedWriteStream.write(inputString + '\n');
}
if (!isWrong) {

@@ -122,3 +134,5 @@ if (automatonTestResult === false && logicTestResult === false) {

incorrect: options.outputFiles?.incorrect ?? true,
input: options.outputFiles?.incorrect ?? true,
input: options.outputFiles?.input ?? true,
accepted: options.outputFiles?.accepted ?? true,
rejected: options.outputFiles?.rejected ?? true,
});

@@ -125,0 +139,0 @@ if (options.type === 'file') {

46

dist/libs/FiniteAutomaton.js

@@ -30,5 +30,7 @@ "use strict";

firstPhaseSet.forEach((state) => {
transitions[state][alphabet]?.forEach((transitionRecordState) => {
secondPhaseSet.add(transitionRecordState);
});
if (transitions[state]) {
transitions[state][alphabet]?.forEach((transitionRecordState) => {
secondPhaseSet.add(transitionRecordState);
});
}
});

@@ -41,3 +43,5 @@ const thirdPhaseSet = new Set();

});
transitionsRecord[alphabet] = Array.from(thirdPhaseSet);
if (transitionsRecord) {
transitionsRecord[alphabet] = Array.from(thirdPhaseSet);
}
}

@@ -200,3 +204,4 @@ });

}
const isTransitionValuesARecord = typeof transitionStatesRecord === 'object' &&
const isTransitionValuesARecord = transitionStatesRecord &&
typeof transitionStatesRecord === 'object' &&
Object.getPrototypeOf(transitionStatesRecord) === Object.prototype;

@@ -245,16 +250,19 @@ if (this.#automatonType === 'deterministic') {

currentParents.forEach((currentParent) => {
const transitionStates = this.automaton.transitions[currentParent.state][symbol];
if (Array.isArray(transitionStates)) {
transitionStates.forEach((transitionState) => {
const parentGraphNode = {
name: transitionState + `(${symbol})`,
state: transitionState,
string: inputString.slice(0, index + 1),
depth: index + 1,
symbol,
children: [],
};
currentParent.children.push(parentGraphNode);
newChildren.push(parentGraphNode);
});
const transitionState = this.automaton.transitions[currentParent.state];
if (transitionState) {
const transitionStates = transitionState[symbol];
if (Array.isArray(transitionStates)) {
transitionStates.forEach((transitionState) => {
const parentGraphNode = {
name: transitionState + `(${symbol})`,
state: transitionState,
string: inputString.slice(0, index + 1),
depth: index + 1,
symbol,
children: [],
};
currentParent.children.push(parentGraphNode);
newChildren.push(parentGraphNode);
});
}
}

@@ -261,0 +269,0 @@ });

{
"name": "fauton",
"version": "0.0.1",
"description": "A small library to get an insight and test any Deterministic finite automaton(DFA) with binary alphabets",
"version": "0.0.2",
"description": "A library to test any finite automaton(FA) with arbitrary alphabets",
"main": "dist/index.js",

@@ -19,2 +19,7 @@ "types": "dist/index.d.ts",

"dfa",
"nfa",
"nfa-to-dfa-conversion",
"finite-automata",
"automaton-testing",
"epsilon-nfa",
"automaton"

@@ -21,0 +26,0 @@ ],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc