-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(utils):
isInt8Array
, isInt16Array
, isInt32Array
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
dfaa227
commit a8d1f1d
Showing
10 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @file Type Tests - isInt16Array | ||
* @module tutils/utils/tests/unit-d/isInt16Array | ||
*/ | ||
|
||
import type testSubject from '../is-int16-array' | ||
|
||
describe('unit-d:utils/isInt16Array', () => { | ||
it('should guard Int16Array', () => { | ||
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<Int16Array>() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @file Unit Tests - isInt16Array | ||
* @module tutils/utils/tests/unit/isInt16Array | ||
*/ | ||
|
||
import testSubject from '../is-int16-array' | ||
|
||
describe('unit:utils/isInt16Array', () => { | ||
it('should return false if value is not Int16Array instance', () => { | ||
expect(testSubject(new Uint16Array())).to.be.false | ||
}) | ||
|
||
it('should return true if value is Int16Array instance', () => { | ||
expect(testSubject(new Int16Array())).to.be.true | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @file Type Tests - isInt32Array | ||
* @module tutils/utils/tests/unit-d/isInt32Array | ||
*/ | ||
|
||
import type testSubject from '../is-int32-array' | ||
|
||
describe('unit-d:utils/isInt32Array', () => { | ||
it('should guard Int32Array', () => { | ||
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<Int32Array>() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @file Unit Tests - isInt32Array | ||
* @module tutils/utils/tests/unit/isInt32Array | ||
*/ | ||
|
||
import testSubject from '../is-int32-array' | ||
|
||
describe('unit:utils/isInt32Array', () => { | ||
it('should return false if value is not Int32Array instance', () => { | ||
expect(testSubject(new Uint32Array())).to.be.false | ||
}) | ||
|
||
it('should return true if value is Int32Array instance', () => { | ||
expect(testSubject(new Int32Array())).to.be.true | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @file Type Tests - isInt8Array | ||
* @module tutils/utils/tests/unit-d/isInt8Array | ||
*/ | ||
|
||
import type testSubject from '../is-int8-array' | ||
|
||
describe('unit-d:utils/isInt8Array', () => { | ||
it('should guard Int8Array', () => { | ||
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<Int8Array>() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @file Unit Tests - isInt8Array | ||
* @module tutils/utils/tests/unit/isInt8Array | ||
*/ | ||
|
||
import testSubject from '../is-int8-array' | ||
|
||
describe('unit:utils/isInt8Array', () => { | ||
it('should return false if value is not Int8Array instance', () => { | ||
expect(testSubject(new Uint8Array())).to.be.false | ||
}) | ||
|
||
it('should return true if value is Int8Array instance', () => { | ||
expect(testSubject(new Int8Array())).to.be.true | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @file Utilities - isInt16Array | ||
* @module tutils/utils/isInt16Array | ||
*/ | ||
|
||
import equal from './equal' | ||
import isObject from './is-object' | ||
|
||
/** | ||
* Checks if `value` is an {@linkcode Int16Array} instance. | ||
* | ||
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Int16Array | ||
* | ||
* @todo examples | ||
* | ||
* @param {unknown} value - Value to check | ||
* @return {value is Int16Array} `true` if `value` is a `Int16Array` | ||
*/ | ||
const isInt16Array = (value: unknown): value is Int16Array => { | ||
return isObject(value) && equal(value.constructor, Int16Array) | ||
} | ||
|
||
export default isInt16Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @file Utilities - isInt32Array | ||
* @module tutils/utils/isInt32Array | ||
*/ | ||
|
||
import equal from './equal' | ||
import isObject from './is-object' | ||
|
||
/** | ||
* Checks if `value` is an {@linkcode Int32Array} instance. | ||
* | ||
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Int32Array | ||
* | ||
* @todo examples | ||
* | ||
* @param {unknown} value - Value to check | ||
* @return {value is Int32Array} `true` if `value` is a `Int32Array` | ||
*/ | ||
const isInt32Array = (value: unknown): value is Int32Array => { | ||
return isObject(value) && equal(value.constructor, Int32Array) | ||
} | ||
|
||
export default isInt32Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @file Utilities - isInt8Array | ||
* @module tutils/utils/isInt8Array | ||
*/ | ||
|
||
import equal from './equal' | ||
import isObject from './is-object' | ||
|
||
/** | ||
* Checks if `value` is an {@linkcode Int8Array} instance. | ||
* | ||
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Int8Array | ||
* | ||
* @todo examples | ||
* | ||
* @param {unknown} value - Value to check | ||
* @return {value is Int8Array} `true` if `value` is a `Int8Array` | ||
*/ | ||
const isInt8Array = (value: unknown): value is Int8Array => { | ||
return isObject(value) && equal(value.constructor, Int8Array) | ||
} | ||
|
||
export default isInt8Array |