Skip to content

Commit 4f30f21

Browse files
authored
feat: add boolean dtype support to array/reviver
PR-URL: stdlib-js#2420 Ref: stdlib-js#2304 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 42c67e7 commit 4f30f21

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/node_modules/@stdlib/array/reviver/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 Uint8Array = require( '@stdlib/array/uint8' );
3131
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
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 //
@@ -46,7 +47,8 @@ var ctors = {
4647
'Uint8Array': Uint8Array,
4748
'Uint8ClampedArray': Uint8ClampedArray,
4849
'Complex64Array': Complex64Array,
49-
'Complex128Array': Complex128Array
50+
'Complex128Array': Complex128Array,
51+
'BooleanArray': BooleanArray
5052
};
5153

5254

lib/node_modules/@stdlib/array/reviver/test/test.js

Lines changed: 19 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) 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.
@@ -35,6 +35,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
3535
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
3636
var Complex64Array = require( '@stdlib/array/complex64' );
3737
var Complex128Array = require( '@stdlib/array/complex128' );
38+
var BooleanArray = require( '@stdlib/array/bool' );
3839
var real = require( '@stdlib/complex/real' );
3940
var realf = require( '@stdlib/complex/realf' );
4041
var imag = require( '@stdlib/complex/imag' );
@@ -156,6 +157,23 @@ tape( 'the function will revive a JSON-serialized typed array (Float32Array)', f
156157
t.end();
157158
});
158159

160+
tape( 'the function will revive a JSON-serialized typed array (BooleanArray)', function test( t ) {
161+
var json;
162+
var arr;
163+
var out;
164+
165+
arr = new BooleanArray( [ true, false ] );
166+
json = JSON.stringify( toJSON( arr ) );
167+
168+
out = parseJSON( json, reviveTypedArray );
169+
170+
t.strictEqual( out instanceof BooleanArray, true, 'is an instance' );
171+
t.strictEqual( out.get( 0 ), arr.get( 0 ), true, 'has expected value' );
172+
t.strictEqual( out.get( 1 ), arr.get( 1 ), true, 'has expected value' );
173+
174+
t.end();
175+
});
176+
159177
tape( 'the function will revive a JSON-serialized typed array (Complex64Array)', function test( t ) {
160178
var json;
161179
var arr;

0 commit comments

Comments
 (0)