add hw2
This commit is contained in:
32
node_modules/@headlessui/react/dist/machines/stack-machine.d.ts
generated
vendored
Normal file
32
node_modules/@headlessui/react/dist/machines/stack-machine.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Machine } from '../machine.js';
|
||||
import { DefaultMap } from '../utils/default-map.js';
|
||||
type Scope = string | null;
|
||||
type Id = string;
|
||||
interface State {
|
||||
stack: Id[];
|
||||
}
|
||||
export declare enum ActionTypes {
|
||||
Push = 0,
|
||||
Pop = 1
|
||||
}
|
||||
export type Actions = {
|
||||
type: ActionTypes.Push;
|
||||
id: Id;
|
||||
} | {
|
||||
type: ActionTypes.Pop;
|
||||
id: Id;
|
||||
};
|
||||
declare class StackMachine extends Machine<State, Actions> {
|
||||
static new(): StackMachine;
|
||||
reduce(state: Readonly<State>, action: Actions): State;
|
||||
actions: {
|
||||
push: (id: Id) => void;
|
||||
pop: (id: Id) => void;
|
||||
};
|
||||
selectors: {
|
||||
isTop: (state: State, id: Id) => boolean;
|
||||
inStack: (state: State, id: Id) => boolean;
|
||||
};
|
||||
}
|
||||
export declare const stackMachines: DefaultMap<Scope, StackMachine>;
|
||||
export {};
|
||||
1
node_modules/@headlessui/react/dist/machines/stack-machine.js
generated
vendored
Normal file
1
node_modules/@headlessui/react/dist/machines/stack-machine.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var a=Object.defineProperty;var r=(e,c,t)=>c in e?a(e,c,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[c]=t;var p=(e,c,t)=>(r(e,typeof c!="symbol"?c+"":c,t),t);import{Machine as d}from'../machine.js';import{DefaultMap as l}from'../utils/default-map.js';import{match as u}from'../utils/match.js';var k=(t=>(t[t.Push=0]="Push",t[t.Pop=1]="Pop",t))(k||{});let y={[0](e,c){let t=c.id,s=e.stack,i=e.stack.indexOf(t);if(i!==-1){let n=e.stack.slice();return n.splice(i,1),n.push(t),s=n,{...e,stack:s}}return{...e,stack:[...e.stack,t]}},[1](e,c){let t=c.id,s=e.stack.indexOf(t);if(s===-1)return e;let i=e.stack.slice();return i.splice(s,1),{...e,stack:i}}};class o extends d{constructor(){super(...arguments);p(this,"actions",{push:t=>this.send({type:0,id:t}),pop:t=>this.send({type:1,id:t})});p(this,"selectors",{isTop:(t,s)=>t.stack[t.stack.length-1]===s,inStack:(t,s)=>t.stack.includes(s)})}static new(){return new o({stack:[]})}reduce(t,s){return u(s.type,y,t,s)}}const x=new l(()=>o.new());export{k as ActionTypes,x as stackMachines};
|
||||
Reference in New Issue
Block a user