This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @module compose | |
*/ | |
interface CallStack { | |
index: number; | |
} | |
export interface Next { | |
(): Promise<void>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @function normalize | |
* @description Normalize the path. | |
* @param path The path to normalize. | |
*/ | |
export function normalize(path: string): string { | |
if (path === '') return '.'; | |
const parts = path.split(/[\\/]+/); | |
const { length } = parts; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @module DFSTree | |
*/ | |
type Resolve<T> = (node: T) => T[] | void; | |
type IteratorValue<T> = [node: T, parent: T | undefined]; | |
type Waiting<T> = [iterator: Iterator<T, undefined>, parent?: T]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @module path | |
*/ | |
/** | |
* @function isURL | |
* @description 判断路径是否为 URL | |
* @param path 需要判断的路径 | |
*/ | |
function isURL(path: string): boolean { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @module useStateMachine | |
* @see https://github.com/cassiozen/useStateMachine | |
*/ | |
import { isFunction, isString } from '/js/utils'; | |
import { Dispatch, useEffect, useMemo, useReducer } from 'react'; | |
type ContextUpdate<C> = (context: C) => C; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @module compose | |
*/ | |
export interface Next { | |
(): Promise<void>; | |
} | |
export interface Composed<C> { | |
(context: C, next?: Next): Promise<void>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @module compose | |
*/ | |
export type Next<C> = (context: C) => Promise<C>; | |
export type Middleware<C> = (context: C, next: Next<C>) => Promise<C> | C; | |
export type ComposedMiddleware<C> = (context: C, next?: Next<C>) => Promise<C>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @module compose | |
*/ | |
export interface Next { | |
(): Promise<void>; | |
} | |
export interface Composed<C> { | |
(context: C, next?: Next): Promise<void>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @function compose | |
* @description compose redux middlewares | |
* @param {function[]} funcs | |
* @returns {function} | |
*/ | |
function compose(middlewares) { | |
return middlewares.reduce((compose, middleware) => { | |
return (...args) => compose(middleware(...args)); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @function compose | |
* @description compose koa middlewares | |
* @param {function[]} middlewares | |
* @returns {function} | |
*/ | |
function compose(middlewares) { | |
const done = async () => {}; | |
const compose = middlewares.reduce((compose, middleware) => { |