@@ -83,10 +83,74 @@ The namespace exports the following:
83
83
<!-- eslint no-undef: "error" -->
84
84
85
85
``` javascript
86
- var objectKeys = require ( ' @stdlib/utils/keys' );
87
86
var ns = require ( ' @stdlib/array/base/assert' );
87
+ var dtype = require ( ' @stdlib/array/dtype' );
88
+ var Float64Array = require ( ' @stdlib/array/float64' );
89
+ var Int32Array = require ( ' @stdlib/array/int32' );
90
+ var Uint8Array = require ( ' @stdlib/array/uint8' );
91
+ var Complex128Array = require ( ' @stdlib/array/complex128' );
88
92
89
- console .log ( objectKeys ( ns ) );
93
+ // Create various arrays:
94
+ var arr1 = new Float64Array ( [ 1.1 , 2.2 , 3.3 ] );
95
+ var arr2 = new Int32Array ( [ 1 , 2 , 3 ] );
96
+ var arr3 = new Uint8Array ( [ 1 , 2 , 3 ] );
97
+ var arr4 = new Complex128Array ( [ 1.0 , 1.0 , 2.0 , 2.0 ] ); // two complex numbers: 1+1i, 2+2i
98
+
99
+ // Get data types:
100
+ var dt1 = dtype ( arr1 );
101
+ var dt2 = dtype ( arr2 );
102
+ var dt3 = dtype ( arr3 );
103
+ var dt4 = dtype ( arr4 );
104
+
105
+ // Check data types:
106
+ console .log ( dt1 + ' is floating-point data type: ' + ns .isFloatingPointDataType ( dt1 ) );
107
+ // => 'float64 is floating-point data type: true'
108
+
109
+ console .log ( dt2 + ' is integer data type: ' + ns .isIntegerDataType ( dt2 ) );
110
+ // => 'int32 is integer data type: true'
111
+
112
+ console .log ( dt3 + ' is unsigned integer data type: ' + ns .isUnsignedIntegerDataType ( dt3 ) );
113
+ // => 'uint8 is unsigned integer data type: true'
114
+
115
+ console .log ( dt4 + ' is complex floating-point data type: ' + ns .isComplexFloatingPointDataType ( dt4 ) );
116
+ // => 'complex128 is complex floating-point data type: true'
117
+
118
+ // Check if arrays have the same values:
119
+ console .log ( ' arr2 and arr3 have same values: ' + ns .hasSameValues ( arr2, arr3 ) );
120
+ // => 'arr2 and arr3 have same values: true'
121
+
122
+ console .log ( ' arr1 and arr2 have same values: ' + ns .hasSameValues ( arr1, arr2 ) );
123
+ // => 'arr1 and arr2 have same values: false'
124
+
125
+ // Check safe data type casts:
126
+ console .log ( ' Can safely cast from ' + dt2 + ' to ' + dt1 + ' : ' + ns .isSafeDataTypeCast ( dt2, dt1 ) );
127
+ // => 'Can safely cast from int32 to float64: true'
128
+
129
+ console .log ( ' Can safely cast from ' + dt1 + ' to ' + dt2 + ' : ' + ns .isSafeDataTypeCast ( dt1, dt2 ) );
130
+ // => 'Can safely cast from float64 to int32: false'
131
+
132
+ console .log ( ' Can safely cast from ' + dt3 + ' to ' + dt2 + ' : ' + ns .isSafeDataTypeCast ( dt3, dt2 ) );
133
+ // => 'Can safely cast from uint8 to int32: true'
134
+
135
+ console .log ( ' Can safely cast from ' + dt4 + ' to ' + dt1 + ' : ' + ns .isSafeDataTypeCast ( dt4, dt1 ) );
136
+ // => 'Can safely cast from complex128 to float64: false'
137
+
138
+ // Check if arrays contain specific values:
139
+ console .log ( ' arr1 contains 2.2: ' + ns .contains ( arr1, 2.2 ) );
140
+ // => 'arr1 contains 2.2: true'
141
+
142
+ console .log ( ' arr2 contains 2: ' + ns .contains ( arr2, 2 ) );
143
+ // => 'arr2 contains 2: true'
144
+
145
+ console .log ( ' arr2 contains 2.2: ' + ns .contains ( arr2, 2.2 ) );
146
+ // => 'arr2 contains 2.2: false'
147
+
148
+ // Check complex array types:
149
+ console .log ( ' arr4 is Complex128Array: ' + ns .isComplex128Array ( arr4 ) );
150
+ // => 'arr4 is Complex128Array: true'
151
+
152
+ console .log ( ' arr4 is complex typed array: ' + ns .isComplexTypedArray ( arr4 ) );
153
+ // => 'arr4 is complex typed array: true'
90
154
```
91
155
92
156
</section >
0 commit comments