Skip to content

Commit c42e729

Browse files
Merge pull request #12 from angular-package/3.4.x
3.4.0
2 parents 43020bf + 790ce10 commit c42e729

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2670
-474
lines changed

README.md

Lines changed: 143 additions & 123 deletions
Large diffs are not rendered by default.

README.temp.md

Lines changed: 2106 additions & 0 deletions
Large diffs are not rendered by default.

packages/type/README.md

Lines changed: 143 additions & 123 deletions
Large diffs are not rendered by default.

packages/type/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/type/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-package/type",
3-
"version": "3.3.2",
3+
"version": "3.4.0",
44
"description": "Common types, type guards and type checkers.",
55
"author": "Angular Package <[email protected]> (https://wvvw.dev)",
66
"homepage": "https://github.com/angular-package/type#readme",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { check } from './check-args.func';
22
/**
33
* Checks if any of all the values are a `string`.
4-
* @param value Any arguments to check if they're all a `'string`.
5-
* @returns A `boolean` indicating whether or not all the `values` are an `Array`.
4+
* @param value Any values to check.
5+
* @returns A `boolean` indicating whether or not all the values are an `Array`.
66
*/
77
export const areString = (...value: any): boolean => check('string', ...value);
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Function.
22
import { isBoolean } from '../../is/lib/is-boolean.func';
33
// Type.
4+
import { AnyBoolean } from '../../type/any-boolean.type';
45
import { GuardBoolean } from '../type/guard-boolean.type';
56
import { ResultCallback } from '../../type/result-callback.type';
67
/**
7-
* Guard the `value` to be a `boolean`.
8-
* @param value A `boolean` type `value` to guard.
9-
* @param callback Optional `ResultCallback` function to handle result before returns.
10-
* @returns A `boolean` indicating whether or not the `value` is a `boolean`.
8+
* Guard the `value` to be any type of a boolean.
9+
* @param value An `AnyBoolean` type `value` to guard.
10+
* @param callback An optional `ResultCallback` function to handle result before returns.
11+
* @returns A `boolean` indicating whether or not the `value` is a `boolean` type or `Boolean` object.
1112
*/
12-
export const guardBoolean: GuardBoolean = (value: boolean, callback?: ResultCallback): value is boolean =>
13+
export const guardBoolean: GuardBoolean = <B extends AnyBoolean>(value: B, callback?: ResultCallback): value is B =>
1314
isBoolean(value, callback);
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Function.
22
import { isNumber } from '../../is/lib/is-number.func';
33
// Type.
4+
import { AnyNumber } from '../../type/any-number.type';
45
import { GuardNumber } from '../type/guard-number.type';
56
import { ResultCallback } from '../../type/result-callback.type';
67
/**
7-
* Guard the `value` to be a `number`.
8-
* @param value A `number` type `value` to guard.
9-
* @param callback Optional `ResultCallback` function to handle result before returns.
10-
* @returns A `boolean` indicating whether or not the `value` is a `number`.
8+
* Guard the `value` to be any type of a number.
9+
* @param value An `AnyNumber` type `value` to guard.
10+
* @param callback An optional `ResultCallback` function to handle result before returns.
11+
* @returns A `boolean` indicating whether or not the `value` is a `number` type or `Number` object.
1112
*/
12-
export const guardNumber: GuardNumber = (value: number, callback?: ResultCallback): value is number =>
13+
export const guardNumber: GuardNumber = <N extends AnyNumber>(value: N, callback?: ResultCallback): value is N =>
1314
isNumber(value, callback);
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Function.
22
import { isString } from '../../is/lib/is-string.func';
33
// Type.
4+
import { AnyString } from '../../type/any-string.type';
45
import { GuardString } from '../type/guard-string.type';
56
import { ResultCallback } from '../../type/result-callback.type';
67
/**
7-
* Guard the `value` to be a `string`.
8-
* @param value A `string` type `value` to guard.
9-
* @param callback Optional `ResultCallback` function to handle result before returns.
10-
* @returns A `boolean` indicating whether or not the `value` is a `string`.
8+
* Guard the `value` to be any type of a string.
9+
* @param value An `AnyString` type `value` to guard.
10+
* @param callback An Optional `ResultCallback` function to handle result before returns.
11+
* @returns A `boolean` indicating whether or not the `value` is a `string` type or `String` object.
1112
*/
12-
export const guardString: GuardString = (value: string, callback?: ResultCallback): value is string =>
13+
export const guardString: GuardString = <S extends AnyString>(value: S, callback?: ResultCallback): value is S =>
1314
isString(value, callback);

packages/type/src/guard/test/guard-boolan.spec.ts renamed to packages/type/src/guard/test/guard-boolean.spec.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Function.
22
import { guardBoolean } from '../lib/guard-boolean.func';
33
// Variables.
4-
import { FALSE_EXPECTATION, TRUE, TRUE_EXPECTATION, FALSE } from './variables/boolean.const';
4+
import { FALSE_EXPECTATION, TRUE, TRUE_EXPECTATION, FALSE, TRUE_INSTANCE, FALSE_INSTANCE } from './variables/boolean.const';
55

66
describe(guardBoolean.name, () => {
77
// Defined.
@@ -16,14 +16,22 @@ describe(guardBoolean.name, () => {
1616
return result;
1717
});
1818
});
19-
2019
// ... primitives.
2120
describe(`primitive`, () => {
2221
// boolean
2322
describe(`boolean`, () => {
24-
it(`${FALSE_EXPECTATION}`, () => expect(guardBoolean(FALSE)).toBe(TRUE));
25-
it(`${TRUE_EXPECTATION}`, () => expect(guardBoolean(TRUE)).toBe(TRUE));
23+
it(`FALSE`, () => expect(guardBoolean(FALSE)).toBe(TRUE));
24+
it(`TRUE`, () => expect(guardBoolean(TRUE)).toBe(TRUE));
25+
});
26+
});
27+
// ... objective.
28+
describe(`objective`, () => {
29+
// boolean
30+
describe(`boolean`, () => {
31+
it(`${TRUE_EXPECTATION}`, () => expect(guardBoolean(TRUE_INSTANCE)).toBe(TRUE));
32+
it(`${FALSE_EXPECTATION}`, () => expect(guardBoolean(FALSE_INSTANCE)).toBe(TRUE));
2633
});
2734
});
35+
2836
});
2937
});

0 commit comments

Comments
 (0)