File tree 3 files changed +17
-0
lines changed
3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export * from './opaqueTypes';
16
16
export * from './environment' ;
17
17
export * from './patchObject' ;
18
18
export * from './isPromise' ;
19
+ export * from './string' ;
19
20
export * from './transformer' ;
20
21
export * from './Percent' ;
21
22
export * from './util' ;
Original file line number Diff line number Diff line change
1
+ export const StringUtils = {
2
+ byteSize : ( str : string ) => new Blob ( [ str ] ) . size
3
+ } ;
Original file line number Diff line number Diff line change
1
+ import { StringUtils } from '../src' ;
2
+
3
+ // Test vectors sourced from https://www.javainuse.com/bytesize
4
+
5
+ describe ( 'StringUtils' , ( ) => {
6
+ describe ( 'byteSize' , ( ) => {
7
+ it ( 'returns the byte size of the string' , ( ) => {
8
+ expect ( StringUtils . byteSize ( 'The quick brown fox jumps over the lazy dog' ) ) . toEqual ( 43 ) ;
9
+ expect ( StringUtils . byteSize ( 'helloWorld!' ) ) . toEqual ( 11 ) ;
10
+ expect ( StringUtils . byteSize ( '👋' ) ) . toEqual ( 4 ) ;
11
+ } ) ;
12
+ } ) ;
13
+ } ) ;
You can’t perform that action at this time.
0 commit comments