Comparing version 1.3.2 to 1.3.3
# Changelog | ||
### `V1.3.3` - 2020-08-20 | ||
* type: Improved TypeScript support. | ||
### `V1.3.2` - 2020-08-20 | ||
@@ -4,0 +7,0 @@ * feat: add `initialState` support. |
@@ -1,2 +0,2 @@ | ||
interface IHistoryOptions { | ||
export interface IHistoryOptions<T = any> { | ||
/** | ||
@@ -6,3 +6,3 @@ * Optional rules array for optimizing data transforming. | ||
*/ | ||
rules?: IRuleOptions[]; | ||
rules?: IRuleOptions<T>[]; | ||
@@ -12,3 +12,3 @@ /** | ||
*/ | ||
initialState?: any; | ||
initialState?: T; | ||
@@ -33,6 +33,6 @@ /** | ||
*/ | ||
onChange?: (state: any) => void; | ||
onChange?: (state: T) => void; | ||
} | ||
interface IRuleOptions { | ||
export interface IRuleOptions<T = any> { | ||
/** | ||
@@ -42,3 +42,3 @@ * Defines whether a rule can be matched. | ||
*/ | ||
match: (state: any) => boolean; | ||
match: (state: T) => boolean; | ||
@@ -48,3 +48,5 @@ /** | ||
*/ | ||
toRecord: (state: any) => { | ||
toRecord: ( | ||
state: T, | ||
) => { | ||
chunks: any[]; | ||
@@ -58,13 +60,10 @@ children?: any[]; | ||
*/ | ||
fromRecord: (shareableChunks: { | ||
chunks: any[], | ||
children: any[] | ||
}) => any; | ||
fromRecord: (shareableChunks: { chunks: any[]; children: any[] }) => T; | ||
} | ||
export class History { | ||
export class History<T = any> { | ||
/** | ||
* Valid record length of current instance | ||
*/ | ||
length: number; | ||
readonly length: number; | ||
@@ -74,3 +73,3 @@ /** | ||
*/ | ||
hasUndo: boolean; | ||
readonly hasUndo: boolean; | ||
@@ -80,3 +79,3 @@ /** | ||
*/ | ||
hasRedo: boolean; | ||
readonly hasRedo: boolean; | ||
@@ -86,3 +85,3 @@ /** | ||
*/ | ||
constructor(options?: IHistoryOptions); | ||
constructor(options?: IHistoryOptions<T>); | ||
@@ -94,3 +93,3 @@ /** | ||
*/ | ||
push(state: any, pickIndex?: number): Promise<History>; | ||
push(state: T, pickIndex?: number): Promise<History>; | ||
@@ -102,3 +101,3 @@ /** | ||
*/ | ||
pushSync(state: any, pickIndex?: number): History; | ||
pushSync(state: T, pickIndex?: number): History; | ||
@@ -118,3 +117,3 @@ /** | ||
*/ | ||
get(): any; | ||
get(): T; | ||
@@ -121,0 +120,0 @@ /** |
{ | ||
"name": "stateshot", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"main": "dist/stateshot.js", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:doodlewind/stateshot.git", |
@@ -12,3 +12,3 @@ # StateShot | ||
<a href="https://unpkg.com/stateshot/dist/stateshot.min.js"> | ||
<img src="http://img.badgesize.io/https://unpkg.com/stateshot/dist/stateshot.min.js?compression=gzip&label=size&maxAge=300"/> | ||
<img src="https://img.shields.io/bundlephobia/minzip/stateshot"/> | ||
</a> | ||
@@ -15,0 +15,0 @@ <a href="https://standardjs.com"> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73172
1055