Skip to content

Commit

Permalink
fix(core): move isDateConstructor and isPrimitiveConstructor from plu…
Browse files Browse the repository at this point in the history
…gins to core
  • Loading branch information
nartc committed Feb 14, 2021
1 parent 66a2f33 commit 997528b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export * from './get.util';

export * from './is-empty.util';
export * from './is-defined.util';
export * from './is-primitive-constructor.util';
export * from './is-date-constructor.util';
8 changes: 8 additions & 0 deletions packages/core/src/lib/utils/is-date-constructor.util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Check if value is a Date constructor
*
* @param {Function} value
*/
export function isDateConstructor(value: unknown): boolean {
return value === Date;
}
10 changes: 10 additions & 0 deletions packages/core/src/lib/utils/is-primitive-constructor.util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Check if value is a String/Number/Boolean/Array constructor
*
* @param {Function} value
*/
export function isPrimitiveConstructor(value: unknown): boolean {
return (
value === String || value === Number || value === Boolean || value === Array
);
}
9 changes: 9 additions & 0 deletions packages/core/src/lib/utils/specs/is-date-constructor.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { isDateConstructor } from '../is-date-constructor.util';

describe('isDateConstructor', () => {
it('should work', () => {
expect(isDateConstructor(Date)).toEqual(true);
expect(isDateConstructor(String)).toEqual(false);
expect(isDateConstructor(Number)).toEqual(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { isPrimitiveConstructor } from '../is-primitive-constructor.util';

describe('isPrimitiveConstructor', () => {
it('should work', () => {
expect(isPrimitiveConstructor(String)).toEqual(true);
expect(isPrimitiveConstructor(Number)).toEqual(true);
expect(isPrimitiveConstructor(Boolean)).toEqual(true);
expect(isPrimitiveConstructor(Array)).toEqual(true);
expect(isPrimitiveConstructor(Date)).toEqual(false);
});
});

0 comments on commit 997528b

Please sign in to comment.