File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 11export function pngChunks ( data ) {
22 const view = new DataView ( data . buffer , 0 ) ;
3- if ( view . getBigUint64 ( 0 ) !== 9894494448401390090n ) throw new Error ( ` Invalid png header` ) ;
3+ if ( view . getBigUint64 ( 0 ) !== 9894494448401390090n ) throw new Error ( ' Invalid png header' ) ;
44
55 const decoder = new TextDecoder ( ) ;
66 const chunks = [ ] ;
Original file line number Diff line number Diff line change 1- import { pngChunks } from './image.js' ;
1+ import { pngChunks , pngInfo } from './image.js' ;
22
33test ( 'pngChunks' , async ( ) => {
44 const blob = await ( await globalThis . fetch ( 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAADUlEQVQIHQECAP3/AAAAAgABzePRKwAAAABJRU5ErkJggg==' ) ) . blob ( ) ;
@@ -8,3 +8,8 @@ test('pngChunks', async () => {
88 { name : 'IEND' , data : new Uint8Array ( [ ] ) } ,
99 ] ) ;
1010} ) ;
11+
12+ test ( 'pngInfo' , async ( ) => {
13+ const blob = await ( await globalThis . fetch ( 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAEElEQVQI12OQNZcAIgYIBQAL8gGxdzzM0A==' ) ) . blob ( ) ;
14+ expect ( await pngInfo ( blob ) ) . toEqual ( { dppx : 2 , width : 2 } ) ;
15+ } ) ;
You can’t perform that action at this time.
0 commit comments