Skip to content

Commit

Permalink
feat(utils): isBigInt64Array, isBigUint64Array
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Jul 20, 2023
1 parent e42c69d commit 4dbd6cc
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils/__tests__/is-big-int64-array.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file Type Tests - isBigInt64Array
* @module tutils/utils/tests/unit-d/isBigInt64Array
*/

import type testSubject from '../is-big-int64-array'

describe('unit-d:utils/isBigInt64Array', () => {
it('should guard BigInt64Array', () => {
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<BigInt64Array>()
})
})
16 changes: 16 additions & 0 deletions src/utils/__tests__/is-big-int64-array.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @file Unit Tests - isBigInt64Array
* @module tutils/utils/tests/unit/isBigInt64Array
*/

import testSubject from '../is-big-int64-array'

describe('unit:utils/isBigInt64Array', () => {
it('should return false if value is not BigInt64Array instance', () => {
expect(testSubject(new BigUint64Array())).to.be.false
})

it('should return true if value is BigInt64Array instance', () => {
expect(testSubject(new BigInt64Array())).to.be.true
})
})
12 changes: 12 additions & 0 deletions src/utils/__tests__/is-big-uint64-array.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file Type Tests - isBigUint64Array
* @module tutils/utils/tests/unit-d/isBigUint64Array
*/

import type testSubject from '../is-big-uint64-array'

describe('unit-d:utils/isBigUint64Array', () => {
it('should guard BigUint64Array', () => {
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<BigUint64Array>()
})
})
16 changes: 16 additions & 0 deletions src/utils/__tests__/is-big-uint64-array.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @file Unit Tests - isBigUint64Array
* @module tutils/utils/tests/unit/isBigUint64Array
*/

import testSubject from '../is-big-uint64-array'

describe('unit:utils/isBigUint64Array', () => {
it('should return false if value is not BigUint64Array instance', () => {
expect(testSubject(new BigInt64Array())).to.be.false
})

it('should return true if value is BigUint64Array instance', () => {
expect(testSubject(new BigUint64Array())).to.be.true
})
})
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export { default as isArray } from './is-array'
export { default as isArrayBuffer } from './is-array-buffer'
export { default as isArrayIndex } from './is-array-index'
export { default as isBigInt } from './is-big-int'
export { default as isBigInt64Array } from './is-big-int64-array'
export { default as isBigUint64Array } from './is-big-uint64-array'
export { default as isBoolean } from './is-boolean'
export { default as isBooleanish } from './is-booleanish'
export { default as isCapitalized } from './is-capitalized'
Expand Down
23 changes: 23 additions & 0 deletions src/utils/is-big-int64-array.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @file Utilities - isBigInt64Array
* @module tutils/utils/isBigInt64Array
*/

import equal from './equal'
import isObject from './is-object'

/**
* Checks if `value` is a {@linkcode BigInt64Array} instance.
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array
*
* @todo examples
*
* @param {unknown} value - Value to check
* @return {value is BigInt64Array} `true` if `value` is an `BigInt64Array`
*/
const isBigInt64Array = (value: unknown): value is BigInt64Array => {
return isObject(value) && equal(value.constructor, BigInt64Array)
}

export default isBigInt64Array
23 changes: 23 additions & 0 deletions src/utils/is-big-uint64-array.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @file Utilities - isBigUint64Array
* @module tutils/utils/isBigUint64Array
*/

import equal from './equal'
import isObject from './is-object'

/**
* Checks if `value` is a {@linkcode BigUint64Array} instance.
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array
*
* @todo examples
*
* @param {unknown} value - Value to check
* @return {value is BigUint64Array} `true` if `value` is an `BigUint64Array`
*/
const isBigUint64Array = (value: unknown): value is BigUint64Array => {
return isObject(value) && equal(value.constructor, BigUint64Array)
}

export default isBigUint64Array

0 comments on commit 4dbd6cc

Please sign in to comment.