Skip to content

feat: add boolean dtype support to array/reviver #2420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/node_modules/@stdlib/array/reviver/lib/ctors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,6 +31,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var BooleanArray = require( '@stdlib/array/bool' );


// MAIN //
Expand All @@ -46,7 +47,8 @@ var ctors = {
'Uint8Array': Uint8Array,
'Uint8ClampedArray': Uint8ClampedArray,
'Complex64Array': Complex64Array,
'Complex128Array': Complex128Array
'Complex128Array': Complex128Array,
'BooleanArray': BooleanArray
};


Expand Down
20 changes: 19 additions & 1 deletion lib/node_modules/@stdlib/array/reviver/test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,6 +35,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var BooleanArray = require( '@stdlib/array/bool' );
var real = require( '@stdlib/complex/real' );
var realf = require( '@stdlib/complex/realf' );
var imag = require( '@stdlib/complex/imag' );
Expand Down Expand Up @@ -156,6 +157,23 @@ tape( 'the function will revive a JSON-serialized typed array (Float32Array)', f
t.end();
});

tape( 'the function will revive a JSON-serialized typed array (BooleanArray)', function test( t ) {
var json;
var arr;
var out;

arr = new BooleanArray( [ true, false ] );
json = JSON.stringify( toJSON( arr ) );

out = parseJSON( json, reviveTypedArray );

t.strictEqual( out instanceof BooleanArray, true, 'is an instance' );
t.strictEqual( out.get( 0 ), arr.get( 0 ), true, 'has expected value' );
t.strictEqual( out.get( 1 ), arr.get( 1 ), true, 'has expected value' );

t.end();
});

tape( 'the function will revive a JSON-serialized typed array (Complex64Array)', function test( t ) {
var json;
var arr;
Expand Down