1- import { Builder , ChildrenSchema , OperatorTask , Propiedades , Schema , SchemaDefinition , WithTaskOptions } from "../models"
1+ import { Builder , ChildrenSchema , DebounceOptions , DebounceSchema , OperatorTask , Propiedades , RequestInitWithUrl , RequestPlainOptions , Schema , SchemaDefinition , WithTaskOptions } from "../models"
22import { reduceRequest , type RequestInfo } from "../helpers/requestHelper"
33
44import {
@@ -10,8 +10,6 @@ import {
1010 formatSortOptions ,
1111 Path ,
1212 removeAccents ,
13- RequestInitWithUrl ,
14- type RequestPlainOptions ,
1513 sortCompare ,
1614 type SortOptions ,
1715 spread ,
@@ -56,8 +54,26 @@ export class Operators implements WithTaskOptions<Operators> {
5654 date = ( value : any , options : Intl . DateTimeFormatOptions & { locale : string } ) => {
5755 return new Date ( value ) . toLocaleString ( options . locale , options )
5856 }
59- debounce = ( fn : ( ...args : [ ] ) => any , ms : number | true ) => {
60- return createDebounce ( fn , ms === true ? 500 : ms )
57+ debounce = ( fn : Function , ms : number | true | Function ) => {
58+ if ( typeof ms == "function" ) {
59+ fn = ms
60+ ms = true
61+ }
62+
63+ return createDebounce ( fn , typeof ms == "number" ? ms : 500 )
64+ }
65+ debounceWith = {
66+ transform : ( { function : fn , ms, target } : DebounceSchema ) => {
67+ return {
68+ propiedades : {
69+ function : target ? target : { function : fn } ,
70+ ms
71+ }
72+ }
73+ } ,
74+ task : ( initial : any , { function : fn , ms } : DebounceOptions ) => {
75+ return this . debounce ( fn , ms )
76+ }
6177 }
6278 entries = entries
6379 spreadStart = ( target : any [ ] , value : any ) => {
@@ -131,8 +147,9 @@ export class Operators implements WithTaskOptions<Operators> {
131147 } ,
132148 task : ( initial : Record < string , any > , current : Record < string , any > ) => current
133149 }
134- request = ( initial : any , options : RequestPlainOptions ) => {
135- return buildRequest ( options )
150+ request = {
151+ transform : ( propiedades : Propiedades ) => ( { propiedades } ) ,
152+ task : ( initial : any , options : RequestPlainOptions ) => buildRequest ( options )
136153 }
137154 reduceFetch = ( requestInit : RequestInitWithUrl , id : any , builder : Builder ) => {
138155 const requestInfo : RequestInfo = {
0 commit comments