Skip to content

Commit 26681a0

Browse files
Jaysukh-409kgryte
andauthored
feat: add boolean dtype support in array/dtype
PR-URL: #2306 Ref: #2304 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 1510858 commit 26681a0

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

lib/node_modules/@stdlib/array/dtype/docs/types/index.d.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2021 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { RealOrComplexTypedArray, Complex128Array, Complex64Array, DataType } from '@stdlib/types/array';
23+
import { RealOrComplexTypedArray, Complex128Array, Complex64Array, BooleanArray, DataType } from '@stdlib/types/array';
2424

2525
/**
2626
* Returns the data type of an array.
@@ -78,6 +78,20 @@ declare function dtype( value: Complex128Array ): 'complex128';
7878
*/
7979
declare function dtype( value: Complex64Array ): 'complex64';
8080

81+
/**
82+
* Returns the data type of an array.
83+
*
84+
* @param value - input value
85+
* @returns data type
86+
*
87+
* @example
88+
* var BooleanArray = require( '@stdlib/array/bool' );
89+
*
90+
* var dt = dtype( new BooleanArray( [ true, false, true, false ] ) );
91+
* // returns 'bool'
92+
*/
93+
declare function dtype( value: BooleanArray ): 'bool';
94+
8195
/**
8296
* Returns the data type of an array.
8397
*

lib/node_modules/@stdlib/array/dtype/docs/types/test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2021 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import Complex128Array = require( '@stdlib/array/complex128' );
2020
import Complex64Array = require( '@stdlib/array/complex64' );
21+
import BooleanArray = require( '@stdlib/array/bool' );
2122
import dtype = require( './index' );
2223

2324

@@ -36,6 +37,7 @@ import dtype = require( './index' );
3637
dtype( new Uint16Array( 10 ) ); // $ExpectType "uint16"
3738
dtype( new Uint8Array( 10 ) ); // $ExpectType "uint8"
3839
dtype( new Uint8ClampedArray( 10 ) ); // $ExpectType "uint8c"
40+
dtype( new BooleanArray( 10 ) ); // $ExpectType "bool"
3941
dtype( [] ); // $ExpectType "generic"
4042
}
4143

lib/node_modules/@stdlib/array/dtype/lib/ctor2dtype.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -33,7 +33,8 @@ var ctor2dtypes = {
3333
'Uint8Array': 'uint8',
3434
'Uint8ClampedArray': 'uint8c',
3535
'Complex64Array': 'complex64',
36-
'Complex128Array': 'complex128'
36+
'Complex128Array': 'complex128',
37+
'BooleanArray': 'bool'
3738
};
3839

3940

lib/node_modules/@stdlib/array/dtype/lib/ctors.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
3131
var Int8Array = require( '@stdlib/array/int8' );
3232
var Complex64Array = require( '@stdlib/array/complex64' );
3333
var Complex128Array = require( '@stdlib/array/complex128' );
34+
var BooleanArray = require( '@stdlib/array/bool' );
3435

3536

3637
// MAIN //
@@ -47,7 +48,8 @@ var CTORS = [
4748
Uint8Array,
4849
Uint8ClampedArray,
4950
Complex64Array,
50-
Complex128Array
51+
Complex128Array,
52+
BooleanArray
5153
];
5254

5355

lib/node_modules/@stdlib/array/dtype/lib/dtypes.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -32,7 +32,8 @@ var DTYPES = [
3232
'uint8',
3333
'uint8c',
3434
'complex64',
35-
'complex128'
35+
'complex128',
36+
'bool'
3637
];
3738

3839

0 commit comments

Comments
 (0)