export interface Class < T > { new ( ... args ) : T ; } export const noop = ( ) => { } ; export function combine < T > ( ... fs ) { return ( x ) => { fs . forEach ( ( f ) => f ( x ) ) ; } ; } export function get < T = any > ( path , value ) { return path . reduce ( ( acc , key ) => { return acc [ key ] ; } , value ) ; } export function mapValues < T , R > ( record , fn ) { const res = { } ; Object . keys ( record ) . forEach ( ( key ) => { res [ key ] = fn ( record [ key ] , key ) ; } ) ; return res ; } export function error ( message ) { console . error ( `[vuex-smart-module] ${ message }` ) ; } export function assert ( condition , message ) { if ( ! condition ) { throw new Error ( `[vuex-smart-module] ${ message }` ) ; } } export function deprecated ( message ) { console . warn ( `[vuex-smart-module] DEPRECATED: ${ message }` ) ; } export function traverseDescriptors ( proto , Base , fn , exclude = { constructor : true } ) { if ( proto . constructor === Base ) { return ; } Object . getOwnPropertyNames ( proto ) . forEach ( ( key ) => { if ( exclude [ key ] ) return ; exclude [ key ] = true ; const desc = Object . getOwnPropertyDescriptor ( proto , key ) ! ; fn ( desc , key ) ; } ) ; traverseDescriptors ( Object . getPrototypeOf ( proto ) , Base , fn , exclude ) ; } export function gatherHandlerNames ( proto , Base ) { const ret = [ ] ; traverseDescriptors ( proto , Base , ( desc , name ) => { if ( typeof desc . value !== 'function' ) { return ; } ret . push ( name ) ; } ) ; return ret ; }