import { Padding } from '../options' ; param { Number | Array } padding return { array } export const formatPadding = ( padding ) : number [ ] => { let top = 0 ; let left = 0 ; let right = 0 ; let bottom = 0 ; if ( typeof padding === 'number' ) { top = left = right = bottom = padding ; } else if ( typeof padding === 'string' ) { const intPadding = parseInt ( padding , 10 ) ; top = left = right = bottom = intPadding ; } else if ( Array . isArray ( padding ) ) { top = padding [ 0 ] ; right = ! isNil ( padding [ 1 ] ) ? padding [ 1 ] : padding [ 0 ] ; bottom = ! isNil ( padding [ 2 ] ) ? padding [ 2 ] : padding [ 0 ] ; left = ! isNil ( padding [ 3 ] ) ? padding [ 3 ] : right ; } return [ top , right , bottom , left ] ; } ; since category param { * } value returns { boolean } example function isNil ( value ) { return value == null ; }