import { Stylesheet } from "@uifabric/merge-styles" ; const CURRENT_ID_PROPERTY = "__currentId__" ; const DEFAULT_ID_STRING = "id__" ; declare const process ; const _global = ( typeof window !== "undefined" && window ) || process ; if ( _global [ CURRENT_ID_PROPERTY ] === undefined ) { _global [ CURRENT_ID_PROPERTY ] = 0 ; } function checkProperties ( a , b ) { for ( const propName in a ) { if ( a . hasOwnProperty ( propName ) ) { if ( ! b . hasOwnProperty ( propName ) || b [ propName ] !== a [ propName ] ) { return false ; } } } return true ; } public export function shallowCompare < TA , TB > ( a , b ) { return checkProperties ( a , b ) && checkProperties ( b , a ) ; } public param target param args returns export function assign ( target , ... args ) { return filteredAssign . apply ( this , [ null , target ] . concat ( args ) ) ; } public param isAllowed param target param args returns export function filteredAssign ( isAllowed , target , ... args ) { target = target || { } ; for ( const sourceObject of args ) { if ( sourceObject ) { for ( const propName in sourceObject ) { if ( sourceObject . hasOwnProperty ( propName ) && ( ! isAllowed || isAllowed ( propName ) ) ) { target [ propName ] = sourceObject [ propName ] ; } } } } return target ; } const stylesheet = Stylesheet . getInstance ( ) ; if ( stylesheet && stylesheet . onReset ) { stylesheet . onReset ( resetIds ) ; } public export function getId ( prefix ? ) { const index = _global [ CURRENT_ID_PROPERTY ] ++ ; return ( prefix || DEFAULT_ID_STRING ) + index ; } public export function resetIds ( counter = 0 ) { _global [ CURRENT_ID_PROPERTY ] = counter ; } export function mapEnumByName < T > ( theEnum , callback ) { return Object . keys ( theEnum ) . map < T | undefined > ( ( p ) => { if ( String ( Number ( p ) ) !== p ) { return callback ( p as string , theEnum [ p ] ) ; } } ) . filter ( ( v ) => ! ! v ) ; } param obj export function values < T > ( obj ) { return Object . keys ( obj ) . reduce ( ( arr , key ) : T [ ] => { arr . push ( obj [ key ] ) ; return arr ; } , [ ] ) ; }