New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

afsm

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

afsm - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2

17

index.d.ts

@@ -10,2 +10,4 @@ import EventEmitter from 'eventemitter3';

action?: string;
success?: (this: IAFSM, result: any) => void;
fail?: (this: IAFSM, err: FSMError) => void;
}

@@ -27,5 +29,3 @@ export declare class MiddleState {

export declare function ChangeState(from: string | string[], to: string, opt?: ChangeOption): (target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;
export declare function tryChangeState(from: string | string[], to: string, opt?: {
ignoreError: boolean;
}): void;
export declare function tryChangeState(from: string | string[], to: string, opt?: ChangeOption): void;
export declare function Includes(...states: string[]): (target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;

@@ -41,7 +41,7 @@ export declare function Excludes(...states: string[]): (target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;

get stateDiagram(): string[];
static STATECHANGED: string;
static UPDATEAFSM: string;
static INIT: string;
static ON: string;
static OFF: string;
static readonly STATECHANGED = "stateChanged";
static readonly UPDATEAFSM = "updateAFSM";
static readonly INIT = "[*]";
static readonly ON = "on";
static readonly OFF = "off";
_state: State;

@@ -55,4 +55,5 @@ [cacheResult]: any;

get state(): State;
set state(value: State);
}
export {};
//# sourceMappingURL=index.d.ts.map

@@ -109,3 +109,5 @@ import EventEmitter from 'eventemitter3';

if (err) {
if (opt.ignoreError)
if (opt.fail)
opt.fail.call(this, err);
else if (opt.ignoreError)
return err;

@@ -130,2 +132,3 @@ else

setState.call(this, to);
opt.success?.call(this, this[cacheResult]);
return this[cacheResult];

@@ -136,4 +139,5 @@ }

setState.call(this, old, msg);
//err = new FSMError(this._state, `action '${action}' failed :${msg}`, err instanceof Error ? err : new Error(msg));
if (opt.ignoreError)
if (opt.fail)
opt.fail.call(this, new FSMError(this._state, `action '${action}' failed :${msg}`, err instanceof Error ? err : new Error(msg)));
else if (opt.ignoreError)
return err;

@@ -250,3 +254,6 @@ else

}
set state(value) {
setState.call(this, value);
}
}
//# sourceMappingURL=index.js.map

@@ -12,2 +12,4 @@ import EventEmitter from 'eventemitter3';

action?: string;
success?: (this: IAFSM, result: any) => void;
fail?: (this: IAFSM, err: FSMError) => void;
}

@@ -87,3 +89,3 @@ // 中间过渡状态

if (this.state === to) return this[cacheResult];
let err: Error | null = null;
let err: FSMError | null = null;
if (Array.isArray(from)) {

@@ -101,3 +103,4 @@ if (from.length == 0) {

if (err) {
if (opt.ignoreError) return err;
if (opt.fail) opt.fail.call(this, err);
else if (opt.ignoreError) return err;
else throw err;

@@ -120,2 +123,3 @@ }

setState.call(this, to);
opt.success?.call(this, this[cacheResult]);
return this[cacheResult];

@@ -125,4 +129,4 @@ } catch (err) {

setState.call(this, old, msg);
//err = new FSMError(this._state, `action '${action}' failed :${msg}`, err instanceof Error ? err : new Error(msg));
if (opt.ignoreError) return err;
if (opt.fail) opt.fail.call(this, new FSMError(this._state, `action '${action}' failed :${msg}`, err instanceof Error ? err : new Error(msg)));
else if (opt.ignoreError) return err;
else throw err;

@@ -133,3 +137,3 @@ }

}
export function tryChangeState(from: string | string[], to: string, opt = { ignoreError: true }) {
export function tryChangeState(from: string | string[], to: string, opt: ChangeOption = { ignoreError: true }) {
ChangeState(from, to, opt);

@@ -208,7 +212,7 @@ }

}
static STATECHANGED = 'stateChanged';
static UPDATEAFSM = 'updateAFSM';
static INIT = "[*]";//初始状态
static ON = "on";
static OFF = "off";
static readonly STATECHANGED = 'stateChanged';
static readonly UPDATEAFSM = 'updateAFSM';
static readonly INIT = "[*]";//初始状态
static readonly ON = "on";
static readonly OFF = "off";
_state: State = FSM.INIT;

@@ -233,2 +237,5 @@ [cacheResult]: any;

}
set state(value: State) {
setState.call(this, value);
}
}
{
"name": "afsm",
"version": "2.3.1",
"version": "2.3.2",
"description": "automatic finite state machine",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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