File tree Expand file tree Collapse file tree 2 files changed +2
-42
lines changed Expand file tree Collapse file tree 2 files changed +2
-42
lines changed Original file line number Diff line number Diff line change 11import sharp from 'sharp' ;
2+ import { parseSizeFactory } from 'avatars-utils' ;
23import { Face } from './FaceFactory' ;
34
4- export type Size = { height : number ; width : number } ;
5-
65const minSize = 40 ;
76const maxSize = 400 ;
87
9- const clamp = ( num : number ) : number => {
10- return Math . min ( Math . max ( num , minSize ) , maxSize ) ;
11- } ;
12-
13- export const parseSize = ( rawSize : string = '' ) : Size => {
14- const [ rawWidth , rawHeight ] = rawSize . toLowerCase ( ) . split ( 'x' ) ;
15- const width = clamp ( Number ( rawWidth ) || maxSize ) ;
16- const height = Number ( rawHeight )
17- ? clamp ( Number ( rawHeight ) || maxSize )
18- : width ;
19-
20- return { width, height } ;
21- } ;
8+ export const parseSize = parseSizeFactory ( minSize , maxSize ) ;
229
2310export const combine = ( face : Face ) =>
2411 sharp ( {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments