import { DateOptions } from '../types' ; export function dateISOify ( obj ) ; export function dateISOify ( obj ) ; export function dateISOify ( obj ) ; export function dateISOify ( obj ) ; api export function dateISOify ( obj ) { if ( obj instanceof Array ) { for ( let i = 0 ; i < obj . length ; i ++ ) { obj [ i ] = dateISOify ( obj [ i ] ) ; } } else if ( obj instanceof Object && ! ( obj instanceof Date ) ) { for ( const key in obj ) { if ( obj [ key ] instanceof Date ) obj [ key ] = toISOString ( obj [ key ] as any ) as any ; } } else { if ( obj instanceof Date ) { obj = toISOString ( obj ) as any ; } } return obj ; } api export function toISOString ( date ) { return date && ! isNaN ( date . getTime ( ) ) ? date . toISOString ( ) : null ; } param { Object } obj param { String } sep param { String } eq param { String } name return { String } api export function stringify ( obj , sep ? , eq ? , name ? ) { sep = sep || '&' ; eq = eq || '=' ; obj = obj === null ? undefined : obj ; if ( typeof obj === 'object' ) { return Object . keys ( obj ) . map ( function ( k ) { if ( Array . isArray ( obj ! [ k ] ) ) { return obj ! [ k ] . map ( function ( v ) { return stringifyPrimitive ( k ) + eq + stringifyPrimitive ( v ) ; } ) . join ( sep ) ; } else { return stringifyPrimitive ( k ) + eq + stringifyPrimitive ( obj ! [ k ] ) ; } } ) . join ( sep ) ; } if ( ! name ) return '' ; return stringifyPrimitive ( name ) + eq + stringifyPrimitive ( obj ) ; } api function stringifyPrimitive ( v ) { switch ( typeof v ) { case 'string' : return v ; case 'boolean' : return v ? 'true' : 'false' ; case 'number' : return isFinite ( v ) ? v . toString ( ) : '' ; default : return '' ; } } api export function escapeSpecialChars ( s ) { return s . replace ( /([\+\-!\(\)\{\}\[\]\^"~\*\?:\\\/])/g , function ( match ) { return '\\' + match ; } ) . replace ( /&&/g , '\\&\\&' ) . replace ( /\|\|/g , '\\|\\|' ) ; }