Browse Source

Removed dead code.

pull/353/head
Sebastian Stehle 7 years ago
parent
commit
451f20cbe5
  1. 1
      src/Squidex/app/framework/internal.ts
  2. 42
      src/Squidex/app/framework/utils/lazy.spec.ts
  3. 24
      src/Squidex/app/framework/utils/lazy.ts
  4. 6
      src/Squidex/app/framework/utils/rxjs-extensions.ts
  5. 15
      src/Squidex/app/framework/utils/string-helper.spec.ts
  6. 4
      src/Squidex/app/framework/utils/string-helper.ts

1
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';

42
src/Squidex/app/framework/utils/lazy.spec.ts

@ -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);
});
});

24
src/Squidex/app/framework/utils/lazy.ts

@ -1,24 +0,0 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
export class Lazy<T> {
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
) {
}
}

6
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) => <T>(source: Observable<T>) =>
dialogs.notifyError(error);
return throwError(error);
}));
export const nextBy = <T>(subject: BehaviorSubject<T>, updater: (value: T) => T) => subject.next(updater(this.value));
}));

15
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);
});
});
});

4
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();
}
}
Loading…
Cancel
Save