From 451f20cbe5ad2bbea668491d452d1942c324a2d9 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 21 Apr 2019 12:18:00 +0200 Subject: [PATCH] Removed dead code. --- src/Squidex/app/framework/internal.ts | 1 - src/Squidex/app/framework/utils/lazy.spec.ts | 42 ------------------- src/Squidex/app/framework/utils/lazy.ts | 24 ----------- .../app/framework/utils/rxjs-extensions.ts | 6 +-- .../app/framework/utils/string-helper.spec.ts | 15 ------- .../app/framework/utils/string-helper.ts | 4 -- 6 files changed, 2 insertions(+), 90 deletions(-) delete mode 100644 src/Squidex/app/framework/utils/lazy.spec.ts delete mode 100644 src/Squidex/app/framework/utils/lazy.ts diff --git a/src/Squidex/app/framework/internal.ts b/src/Squidex/app/framework/internal.ts index 16521e1bc..776e7df49 100644 --- a/src/Squidex/app/framework/internal.ts +++ b/src/Squidex/app/framework/internal.ts @@ -25,7 +25,6 @@ export * from './utils/duration'; export * from './utils/error'; export * from './utils/interpolator'; export * from './utils/immutable-array'; -export * from './utils/lazy'; export * from './utils/math-helper'; export * from './utils/modal-positioner'; export * from './utils/modal-view'; diff --git a/src/Squidex/app/framework/utils/lazy.spec.ts b/src/Squidex/app/framework/utils/lazy.spec.ts deleted file mode 100644 index 60d720ab1..000000000 --- a/src/Squidex/app/framework/utils/lazy.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. - */ - -import { Lazy } from './lazy'; - -describe('Lazy', () => { - it('should provider value', () => { - const lazy = new Lazy(() => 1); - - expect(lazy.value).toBe(1); - }); - - it('should call delegate once', () => { - let called = 0; - - const lazy = new Lazy(() => { - called++; - return 13; - }); - - expect(lazy.value).toBe(13); - expect(lazy.value).toBe(13); - expect(called).toBe(1); - }); - - it('should call delegate once when returned undefined', () => { - let called = 0; - - const lazy = new Lazy(() => { - called++; - return undefined; - }); - - expect(lazy.value).toBeUndefined(); - expect(lazy.value).toBeUndefined(); - expect(called).toBe(1); - }); -}); \ No newline at end of file diff --git a/src/Squidex/app/framework/utils/lazy.ts b/src/Squidex/app/framework/utils/lazy.ts deleted file mode 100644 index 4227aed92..000000000 --- a/src/Squidex/app/framework/utils/lazy.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Squidex Headless CMS - * - * @license - * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. - */ - -export class Lazy { - private valueSet = false; - private valueField: T; - - public get value(): T { - if (!this.valueSet) { - this.valueField = this.factory(); - this.valueSet = true; - } - - return this.valueField; - } - constructor( - private readonly factory: () => T - ) { - } -} \ No newline at end of file diff --git a/src/Squidex/app/framework/utils/rxjs-extensions.ts b/src/Squidex/app/framework/utils/rxjs-extensions.ts index 2d2d86786..37211ea59 100644 --- a/src/Squidex/app/framework/utils/rxjs-extensions.ts +++ b/src/Squidex/app/framework/utils/rxjs-extensions.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { BehaviorSubject, Observable, throwError } from 'rxjs'; +import { Observable, throwError } from 'rxjs'; import { catchError } from 'rxjs/operators'; import { DialogService } from './../services/dialog.service'; @@ -17,6 +17,4 @@ export const notify = (dialogs: DialogService) => (source: Observable) => dialogs.notifyError(error); return throwError(error); - })); - -export const nextBy = (subject: BehaviorSubject, updater: (value: T) => T) => subject.next(updater(this.value)); \ No newline at end of file + })); \ No newline at end of file diff --git a/src/Squidex/app/framework/utils/string-helper.spec.ts b/src/Squidex/app/framework/utils/string-helper.spec.ts index c3e912021..a08b4d0b1 100644 --- a/src/Squidex/app/framework/utils/string-helper.spec.ts +++ b/src/Squidex/app/framework/utils/string-helper.spec.ts @@ -38,19 +38,4 @@ describe('StringHelper', () => { it('should return empty string if also fallback not found', () => { expect(StringHelper.firstNonEmpty(null!, undefined!, '')).toBe(''); }); - - [ - { src: '', result: '' }, - { src: 'M', result: 'm' }, - { src: 'My', result: 'my' }, - { src: 'M-y', result: 'mY' }, - { src: 'MyProperty ', result: 'myProperty' }, - { src: 'My property', result: 'myProperty' }, - { src: 'My_property', result: 'myProperty' }, - { src: 'My-property', result: 'myProperty' } - ].forEach(test => { - it(`should return convert ${test.src} to camel case`, () => { - expect(StringHelper.toCamelCase(test.src)).toBe(test.result); - }); - }); }); \ No newline at end of file diff --git a/src/Squidex/app/framework/utils/string-helper.ts b/src/Squidex/app/framework/utils/string-helper.ts index 6655d5488..778da4c2a 100644 --- a/src/Squidex/app/framework/utils/string-helper.ts +++ b/src/Squidex/app/framework/utils/string-helper.ts @@ -19,8 +19,4 @@ export module StringHelper { return ''; } - - export function toCamelCase(value: string) { - return value.replace(/[^\s\-_]+/g, (w, i) => (i === 0 ? w[0].toLowerCase() : w[0].toUpperCase()) + w.slice(1)).replace(/[\s\-_]+/g, '').trim(); - } } \ No newline at end of file