Skip to content

Commit a589f6b

Browse files
committed
Add string polyfills
1 parent 10a3a6e commit a589f6b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/app/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ import de_CHTranslation from './../locales/de_CH.json';
2828
import 'isomorphic-fetch';
2929
import LanguageDetector from 'i18next-browser-languagedetector';
3030

31+
/**
32+
* Polyfills
33+
*/
34+
import 'utils/polyfills.utils';
35+
3136
// Fontawesome setup
3237
import fontawesome from '@fortawesome/fontawesome';
3338
import fontawesomeSolid from '@fortawesome/fontawesome-free-solid';

src/app/utils/polyfills.utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// tslint:disable-next-line:interface-name
2+
interface StringConstructor {
3+
isEmpty(str: string | undefined): boolean;
4+
emptyIfUndefined(str: string): string;
5+
}
6+
7+
// tslint:disable-next-line:no-null-keyword
8+
String.isEmpty = str => str === undefined || str === null || str.length === 0;
9+
10+
String.emptyIfUndefined = str => String.isEmpty(str) ? '' : str;

0 commit comments

Comments
 (0)